Skip to content

Commit

Permalink
Fixed shadowed variable warnings
Browse files Browse the repository at this point in the history
- Fixed shadowed variable warnings in lfs_dir_find.
- Fixed unused parameter warnings when LFS_NO_MALLOC is enabled.
- Added extra warning flags to CFLAGS.
- Updated tests so they don't shadow the "size" variable for -Wshadow
  • Loading branch information
dpgeorge authored and geky committed Jul 2, 2018
1 parent 93a2e0b commit 51346b8
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -22,7 +22,7 @@ ifdef WORD
override CFLAGS += -m$(WORD)
endif
override CFLAGS += -I.
override CFLAGS += -std=c99 -Wall -pedantic
override CFLAGS += -std=c99 -Wall -pedantic -Wshadow -Wunused-parameter


all: $(TARGET)
Expand Down
2 changes: 1 addition & 1 deletion lfs.c
Expand Up @@ -836,7 +836,7 @@ static int lfs_dir_find(lfs_t *lfs, lfs_dir_t *dir,

// find entry matching name
while (true) {
int err = lfs_dir_next(lfs, dir, entry);
err = lfs_dir_next(lfs, dir, entry);
if (err) {
return err;
}
Expand Down
3 changes: 3 additions & 0 deletions lfs_util.h
Expand Up @@ -158,6 +158,7 @@ static inline void *lfs_malloc(size_t size) {
#ifndef LFS_NO_MALLOC
return malloc(size);
#else
(void)size;
return NULL;
#endif
}
Expand All @@ -166,6 +167,8 @@ static inline void *lfs_malloc(size_t size) {
static inline void lfs_free(void *p) {
#ifndef LFS_NO_MALLOC
free(p);
#else
(void)p;
#endif
}

Expand Down
4 changes: 2 additions & 2 deletions tests/test_files.sh
Expand Up @@ -30,7 +30,7 @@ TEST

w_test() {
tests/test.py << TEST
lfs_size_t size = $1;
size = $1;
lfs_size_t chunk = 31;
srand(0);
lfs_mount(&lfs, &cfg) => 0;
Expand All @@ -50,7 +50,7 @@ TEST

r_test() {
tests/test.py << TEST
lfs_size_t size = $1;
size = $1;
lfs_size_t chunk = 29;
srand(0);
lfs_mount(&lfs, &cfg) => 0;
Expand Down
8 changes: 4 additions & 4 deletions tests/test_seek.sh
Expand Up @@ -153,7 +153,7 @@ tests/test.py << TEST
lfs_file_read(&lfs, &file[0], buffer, size) => size;
memcmp(buffer, "kittycatcat", size) => 0;
lfs_size_t size = lfs_file_size(&lfs, &file[0]);
size = lfs_file_size(&lfs, &file[0]);
lfs_file_seek(&lfs, &file[0], 0, LFS_SEEK_CUR) => size;
lfs_file_close(&lfs, &file[0]) => 0;
Expand Down Expand Up @@ -202,7 +202,7 @@ tests/test.py << TEST
lfs_file_read(&lfs, &file[0], buffer, size) => size;
memcmp(buffer, "kittycatcat", size) => 0;
lfs_size_t size = lfs_file_size(&lfs, &file[0]);
size = lfs_file_size(&lfs, &file[0]);
lfs_file_seek(&lfs, &file[0], 0, LFS_SEEK_CUR) => size;
lfs_file_close(&lfs, &file[0]) => 0;
Expand Down Expand Up @@ -243,7 +243,7 @@ tests/test.py << TEST
lfs_file_read(&lfs, &file[0], buffer, size) => size;
memcmp(buffer, "kittycatcat", size) => 0;
lfs_size_t size = lfs_file_size(&lfs, &file[0]);
size = lfs_file_size(&lfs, &file[0]);
lfs_file_seek(&lfs, &file[0], 0, LFS_SEEK_CUR) => size;
lfs_file_close(&lfs, &file[0]) => 0;
Expand Down Expand Up @@ -286,7 +286,7 @@ tests/test.py << TEST
lfs_file_read(&lfs, &file[0], buffer, size) => size;
memcmp(buffer, "kittycatcat", size) => 0;
lfs_size_t size = lfs_file_size(&lfs, &file[0]);
size = lfs_file_size(&lfs, &file[0]);
lfs_file_seek(&lfs, &file[0], 0, LFS_SEEK_CUR) => size;
lfs_file_close(&lfs, &file[0]) => 0;
Expand Down

0 comments on commit 51346b8

Please sign in to comment.