Skip to content

Commit 8c7b6b2

Browse files
authored
fix: false uninitialized read warning
Add asserts on file system reads to make sure no positive values are returned, which would make assumptions on error checks invalid. This fixes clang tidy warnings on uninitialized reads in uses of lfs_dir_get where only negative returns are considered errors.
1 parent 8e251dd commit 8c7b6b2

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lfs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,7 @@ static lfs_stag_t lfs_dir_getslice(lfs_t *lfs, const lfs_mdir_t *dir,
739739
int err = lfs_bd_read(lfs,
740740
NULL, &lfs->rcache, sizeof(ntag),
741741
dir->pair[0], off, &ntag, sizeof(ntag));
742+
LFS_ASSERT(err <= 0);
742743
if (err) {
743744
return err;
744745
}
@@ -767,6 +768,7 @@ static lfs_stag_t lfs_dir_getslice(lfs_t *lfs, const lfs_mdir_t *dir,
767768
err = lfs_bd_read(lfs,
768769
NULL, &lfs->rcache, diff,
769770
dir->pair[0], off+sizeof(tag)+goff, gbuffer, diff);
771+
LFS_ASSERT(err <= 0);
770772
if (err) {
771773
return err;
772774
}

0 commit comments

Comments
 (0)