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.
This commit is contained in:
Joakim Plate
2025-08-12 14:56:29 +02:00
committed by GitHub
parent 8e251dd675
commit 8c7b6b26e6

2
lfs.c
View File

@@ -739,6 +739,7 @@ static lfs_stag_t lfs_dir_getslice(lfs_t *lfs, const lfs_mdir_t *dir,
int err = lfs_bd_read(lfs,
NULL, &lfs->rcache, sizeof(ntag),
dir->pair[0], off, &ntag, sizeof(ntag));
LFS_ASSERT(err <= 0);
if (err) {
return err;
}
@@ -767,6 +768,7 @@ static lfs_stag_t lfs_dir_getslice(lfs_t *lfs, const lfs_mdir_t *dir,
err = lfs_bd_read(lfs,
NULL, &lfs->rcache, diff,
dir->pair[0], off+sizeof(tag)+goff, gbuffer, diff);
LFS_ASSERT(err <= 0);
if (err) {
return err;
}