ibm-capi / capi-utils

Utilities for CAPI adapters
Other
7 stars 12 forks source link

Suggestion: Fix the warnings which occur when compiling with -W -Wall #9

Closed fhaverkamp closed 7 years ago

fhaverkamp commented 7 years ago

haver@tul2eth3:~/capi-utils$ make gcc -Wall -W -g -O2 src/capi_flash_ad7v3ku3_user.c -o capi-flash-AlphaData7v3 src/capi_flash_ad7v3ku3_user.c: In function 'main': src/capi_flash_ad7v3ku3_user.c:36:13: warning: unused variable 'priv2' [-Wunused-variable] int priv1,priv2; ^ src/capi_flash_ad7v3ku3_user.c:36:7: warning: unused variable 'priv1' [-Wunused-variable] int priv1,priv2; ^ src/capi_flash_ad7v3ku3_user.c:70:3: warning: ignoring return value of 'read', declared with attribute warn_unused_result [-Wunused-result] read(CFG, &temp, 4); ^ src/capi_flash_ad7v3ku3_user.c:83:3: warning: ignoring return value of 'read', declared with attribute warn_unused_result [-Wunused-result] read(CFG, &temp,4); ^ src/capi_flash_ad7v3ku3_user.c:107:3: warning: ignoring return value of 'write', declared with attribute warn_unused_result [-Wunused-result] write(CFG,&temp,4); ^ src/capi_flash_ad7v3ku3_user.c:114:3: warning: ignoring return value of 'read', declared with attribute warn_unused_result [-Wunused-result] read(CFG,&temp,4); ^ src/capi_flash_ad7v3ku3_user.c:123:5: warning: ignoring return value of 'read', declared with attribute warn_unused_result [-Wunused-result] read(CFG,&temp,4); ^ src/capi_flash_ad7v3ku3_user.c:159:3: warning: ignoring return value of 'write', declared with attribute warn_unused_result [-Wunused-result] write(CFG,&address,4); ...

I think the warnings are not really critical, but in case something does not work as expected, you continue to write/read even though it is already in broken state. So maybe adding a little check which prints something meaningful and gracefully exists, is a good idea from my perspective.

Seeing warnings in such critical code like flash update makes me nervous.

Thanks

Frank

kenhill commented 7 years ago

The warnings have been resolved with an assert statement

fhaverkamp commented 7 years ago

Wonderful!