Skip to content

Commit 447d89c

Browse files
authored
Merge pull request #109 from OTAkeys/pr/fix-sign-compare
Fix -Wsign-compare error
2 parents cb62bf2 + 28d2d96 commit 447d89c

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ override CFLAGS += -m$(WORD)
2626
endif
2727
override CFLAGS += -I.
2828
override CFLAGS += -std=c99 -Wall -pedantic
29-
override CFLAGS += -Wshadow -Wunused-parameter -Wjump-misses-init
29+
override CFLAGS += -Wshadow -Wunused-parameter -Wjump-misses-init -Wsign-compare
3030

3131

3232
all: $(TARGET)

lfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2481,7 +2481,7 @@ int lfs_deorphan(lfs_t *lfs) {
24812481
lfs_dir_t cwd = {.d.tail[0] = 0, .d.tail[1] = 1};
24822482

24832483
// iterate over all directory directory entries
2484-
for (int i = 0; i < lfs->cfg->block_count; i++) {
2484+
for (lfs_size_t i = 0; i < lfs->cfg->block_count; i++) {
24852485
if (lfs_pairisnull(cwd.d.tail)) {
24862486
return 0;
24872487
}

tests/test_alloc.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,18 @@ lfs_alloc_singleproc() {
3232
tests/test.py << TEST
3333
const char *names[] = {"bacon", "eggs", "pancakes"};
3434
lfs_mount(&lfs, &cfg) => 0;
35-
for (int n = 0; n < sizeof(names)/sizeof(names[0]); n++) {
35+
for (unsigned n = 0; n < sizeof(names)/sizeof(names[0]); n++) {
3636
sprintf((char*)buffer, "$1/%s", names[n]);
3737
lfs_file_open(&lfs, &file[n], (char*)buffer,
3838
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_APPEND) => 0;
3939
}
40-
for (int n = 0; n < sizeof(names)/sizeof(names[0]); n++) {
40+
for (unsigned n = 0; n < sizeof(names)/sizeof(names[0]); n++) {
4141
size = strlen(names[n]);
4242
for (int i = 0; i < $SIZE; i++) {
4343
lfs_file_write(&lfs, &file[n], names[n], size) => size;
4444
}
4545
}
46-
for (int n = 0; n < sizeof(names)/sizeof(names[0]); n++) {
46+
for (unsigned n = 0; n < sizeof(names)/sizeof(names[0]); n++) {
4747
lfs_file_close(&lfs, &file[n]) => 0;
4848
}
4949
lfs_unmount(&lfs) => 0;

tests/test_seek.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ tests/test.py << TEST
301301
size = strlen("hedgehoghog");
302302
const lfs_soff_t offsets[] = {512, 1020, 513, 1021, 511, 1019};
303303
304-
for (int i = 0; i < sizeof(offsets) / sizeof(offsets[0]); i++) {
304+
for (unsigned i = 0; i < sizeof(offsets) / sizeof(offsets[0]); i++) {
305305
lfs_soff_t off = offsets[i];
306306
memcpy(buffer, "hedgehoghog", size);
307307
lfs_file_seek(&lfs, &file[0], off, LFS_SEEK_SET) => off;

tests/test_truncate.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ tests/test.py << TEST
2323
2424
lfs_mount(&lfs, &cfg) => 0;
2525
26-
for (int i = 0; i < sizeof(startsizes)/sizeof(startsizes[0]); i++) {
26+
for (unsigned i = 0; i < sizeof(startsizes)/sizeof(startsizes[0]); i++) {
2727
sprintf((char*)buffer, "hairyhead%d", i);
2828
lfs_file_open(&lfs, &file[0], (const char*)buffer,
2929
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
3030
3131
strcpy((char*)buffer, "hair");
3232
size = strlen((char*)buffer);
33-
for (int j = 0; j < startsizes[i]; j += size) {
33+
for (lfs_off_t j = 0; j < startsizes[i]; j += size) {
3434
lfs_file_write(&lfs, &file[0], buffer, size) => size;
3535
}
3636
lfs_file_size(&lfs, &file[0]) => startsizes[i];
@@ -55,13 +55,13 @@ tests/test.py << TEST
5555
5656
lfs_mount(&lfs, &cfg) => 0;
5757
58-
for (int i = 0; i < sizeof(startsizes)/sizeof(startsizes[0]); i++) {
58+
for (unsigned i = 0; i < sizeof(startsizes)/sizeof(startsizes[0]); i++) {
5959
sprintf((char*)buffer, "hairyhead%d", i);
6060
lfs_file_open(&lfs, &file[0], (const char*)buffer, LFS_O_RDWR) => 0;
6161
lfs_file_size(&lfs, &file[0]) => hotsizes[i];
6262
6363
size = strlen("hair");
64-
int j = 0;
64+
lfs_off_t j = 0;
6565
for (; j < startsizes[i] && j < hotsizes[i]; j += size) {
6666
lfs_file_read(&lfs, &file[0], buffer, size) => size;
6767
memcmp(buffer, "hair", size) => 0;
@@ -87,13 +87,13 @@ tests/test.py << TEST
8787
8888
lfs_mount(&lfs, &cfg) => 0;
8989
90-
for (int i = 0; i < sizeof(startsizes)/sizeof(startsizes[0]); i++) {
90+
for (unsigned i = 0; i < sizeof(startsizes)/sizeof(startsizes[0]); i++) {
9191
sprintf((char*)buffer, "hairyhead%d", i);
9292
lfs_file_open(&lfs, &file[0], (const char*)buffer, LFS_O_RDONLY) => 0;
9393
lfs_file_size(&lfs, &file[0]) => coldsizes[i];
9494
9595
size = strlen("hair");
96-
int j = 0;
96+
lfs_off_t j = 0;
9797
for (; j < startsizes[i] && j < hotsizes[i] && j < coldsizes[i];
9898
j += size) {
9999
lfs_file_read(&lfs, &file[0], buffer, size) => size;

0 commit comments

Comments
 (0)