Skip to content

Commit 69da2b1

Browse files
Check for shadowing in lfs.c and ensure clean compilation
1 parent adad0fb commit 69da2b1

File tree

2 files changed

+29
-21
lines changed

2 files changed

+29
-21
lines changed

lfs.c

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "lfs_util.h"
1010

1111

12+
1213
// some constants used throughout the code
1314
#define LFS_BLOCK_NULL ((lfs_block_t)-1)
1415
#define LFS_BLOCK_INLINE ((lfs_block_t)-2)
@@ -1769,9 +1770,9 @@ static int lfs_dir_commitcrc(lfs_t *lfs, struct lfs_commit *commit) {
17691770
// the caching layer
17701771
if (noff >= end || noff >= lfs->pcache.off + lfs->cfg->cache_size) {
17711772
// flush buffers
1772-
int err = lfs_bd_sync(lfs, &lfs->pcache, &lfs->rcache, false);
1773-
if (err) {
1774-
return err;
1773+
int sync_err = lfs_bd_sync(lfs, &lfs->pcache, &lfs->rcache, false);
1774+
if (sync_err) {
1775+
return sync_err;
17751776
}
17761777
}
17771778
}
@@ -4722,16 +4723,16 @@ int lfs_fs_traverse_(lfs_t *lfs,
47224723
}
47234724

47244725
for (int i = 0; i < 2; i++) {
4725-
int err = cb(data, dir.tail[i]);
4726-
if (err) {
4727-
return err;
4726+
int traverse_err = cb(data, dir.tail[i]);
4727+
if (traverse_err) {
4728+
return traverse_err;
47284729
}
47294730
}
47304731

47314732
// iterate through ids in directory
4732-
int err = lfs_dir_fetch(lfs, &dir, dir.tail);
4733-
if (err) {
4734-
return err;
4733+
int fetch_err = lfs_dir_fetch(lfs, &dir, dir.tail);
4734+
if (fetch_err) {
4735+
return fetch_err;
47354736
}
47364737

47374738
for (uint16_t id = 0; id < dir.count; id++) {
@@ -4772,18 +4773,18 @@ int lfs_fs_traverse_(lfs_t *lfs,
47724773
}
47734774

47744775
if ((f->flags & LFS_F_DIRTY) && !(f->flags & LFS_F_INLINE)) {
4775-
int err = lfs_ctz_traverse(lfs, &f->cache, &lfs->rcache,
4776+
int err_traverse = lfs_ctz_traverse(lfs, &f->cache, &lfs->rcache,
47764777
f->ctz.head, f->ctz.size, cb, data);
4777-
if (err) {
4778+
if (err_traverse ) {
47784779
return err;
47794780
}
47804781
}
47814782

47824783
if ((f->flags & LFS_F_WRITING) && !(f->flags & LFS_F_INLINE)) {
4783-
int err = lfs_ctz_traverse(lfs, &f->cache, &lfs->rcache,
4784+
int err_traverse = lfs_ctz_traverse(lfs, &f->cache, &lfs->rcache,
47844785
f->block, f->pos, cb, data);
4785-
if (err) {
4786-
return err;
4786+
if (err_traverse ) {
4787+
return err_traverse ;
47874788
}
47884789
}
47894790
}
@@ -4803,10 +4804,10 @@ static int lfs_fs_pred(lfs_t *lfs,
48034804
.i = 1,
48044805
.period = 1,
48054806
};
4806-
int err = LFS_ERR_OK;
4807+
int err1 = LFS_ERR_OK;
48074808
while (!lfs_pair_isnull(pdir->tail)) {
4808-
err = lfs_tortoise_detectcycles(pdir, &tortoise);
4809-
if (err < 0) {
4809+
err1 = lfs_tortoise_detectcycles(pdir, &tortoise);
4810+
if (err1 < 0) {
48104811
return LFS_ERR_CORRUPT;
48114812
}
48124813

@@ -4863,11 +4864,11 @@ static lfs_stag_t lfs_fs_parent(lfs_t *lfs, const lfs_block_t pair[2],
48634864
.i = 1,
48644865
.period = 1,
48654866
};
4866-
int err = LFS_ERR_OK;
4867+
int err2 = LFS_ERR_OK;
48674868
while (!lfs_pair_isnull(parent->tail)) {
4868-
err = lfs_tortoise_detectcycles(parent, &tortoise);
4869-
if (err < 0) {
4870-
return err;
4869+
err2 = lfs_tortoise_detectcycles(parent, &tortoise);
4870+
if (err2 < 0) {
4871+
return err2;
48714872
}
48724873

48734874
lfs_stag_t tag = lfs_dir_fetchmatch(lfs, parent, parent->tail,

test_main.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// test_main.c
2+
#include <stdio.h>
3+
4+
int main(void) {
5+
printf("Test program started.\n");
6+
return 0;
7+
}

0 commit comments

Comments
 (0)