Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lots of static analysis bugs #6

Closed
mkschreder opened this issue Feb 9, 2015 · 5 comments
Closed

Lots of static analysis bugs #6

mkschreder opened this issue Feb 9, 2015 · 5 comments
Assignees

Comments

@mkschreder
Copy link

spiffs_nucleus.c spiffs_object_modify line 1218 new_objix_pix is never initialized
spiffs_nucleus.c spiffs_obj_lu_find_free_obj_id line 1710 possible division by zero

state.compaction = (state.max_obj_id-state.min_obj_id) / ((SPIFFS_CFG_LOG_PAGE_SZ(fs) / sizeof(u8_t)));

Also lots of warnings for never read result value. Better to not store result at all otherwise written code has no effect.

spiffs_nucleus.c spiffs_object_modify line 1135 value of res is never read
spiffs_hydrogen.c SPIFFS_write line 324 value of res never read
spiffs_hydrogen.c SPIFFS_check line 700 res never read
...

@pellepl
Copy link
Owner

pellepl commented Feb 10, 2015

Could you please inform me of what compiler and with what flags you encounter this? And what flags are you using in spiffs_config.h?

@pellepl pellepl self-assigned this Feb 10, 2015
@mkschreder
Copy link
Author

Clang scan-build with arm-none-eabi-gcc with -Wall

@pellepl
Copy link
Owner

pellepl commented Feb 10, 2015

Ok thanks. Seems plain linux gcc -Wall does not report as much as an arm cross-compiled gcc. Weird. I'll look into it and fix it.

@mkschreder
Copy link
Author

For maximum effect:

gcc:
-Wall -Wno-format-y2k -W -Wstrict-prototypes -Wmissing-prototypes
-Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch
-Wshadow -Wcast-align -Wchar-subscripts -Winline
-Wnested-externs -Wredundant-decls

g++:
-Wall -Wno-format-y2k -W
-Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch
-Wcast-align -Wchar-subscripts -Wredundant-decls

pellepl added a commit that referenced this issue Feb 10, 2015
@pellepl
Copy link
Owner

pellepl commented Feb 10, 2015

Fixed. Phew. Found one bug amongst all warnings. Thanks!

@pellepl pellepl closed this as completed Feb 10, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants