You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are getting a number of Compiler Warnings when building Zephyr 1.14 (See below).
The variable rc is not initialized in these functions and could potentially get returned without being set to a value. In actual fact it may not be possible for this to happen due to the values passed into these functions being correct, but the Compiler cannot determine this, and it would be safer to actively prevent this possibility in the functions themselves.
Can you please advise on the best way to correct these warnings?
It seems that simply initializing the rc variables to an invalid value when they are declared would achieve this - do you agree?
Regards,
Declan Traill
Setec Pty Ltd
[50/254] Building C object zephyr/CMakeFiles/zephyr.dir/subsys/settings/src/settings_store.c.obj
C:/Users/declan.traill/RVMN101/zephyr/subsys/settings/src/settings_store.c: In function 'settings_cmp':
C:/Users/declan.traill/RVMN101/zephyr/subsys/settings/src/settings_store.c:113:9: warning: 'rc' may be used uninitialized in this function [-Wmaybe-uninitialized]
return rc;
^~
[52/254] Building C object zephyr/CMakeFiles/zephyr.dir/subsys/settings/src/settings_line.c.obj
C:/Users/declan.traill/RVMN101/zephyr/subsys/settings/src/settings_line.c: In function 'settings_line_raw_read_until':
C:/Users/declan.traill/RVMN101/zephyr/subsys/settings/src/settings_line.c:272:19: warning: 'rc' may be used uninitialized in this function [-Wmaybe-uninitialized]
return (rc) ? 0 : 1;
~~~~~~~~~^~~
C:/Users/declan.traill/RVMN101/zephyr/subsys/settings/src/settings_line.c: In function 'settings_entry_copy':
C:/Users/declan.traill/RVMN101/zephyr/subsys/settings/src/settings_line.c:444:9: warning: 'rc' may be used uninitialized in this function [-Wmaybe-uninitialized]
return rc;
^~
[55/254] Building C object zephyr/CMakeFiles/zephyr.dir/subsys/settings/src/settings_fcb.c.obj
C:/Users/declan.traill/RVMN101/zephyr/subsys/settings/src/settings_fcb.c: In function 'settings_fcb_save':
C:/Users/declan.traill/RVMN101/zephyr/subsys/settings/src/settings_fcb.c:270:5: warning: 'rc' may be used uninitialized in this function [-Wmaybe-uninitialized]
if (rc) {
^
The text was updated successfully, but these errors were encountered:
@DeclanTraill do we get the same warnings in master?
Looking at master, some of the code has changed but some still have the compiler warning issue.
Also, we noticed that the warnings seem to only happen in a Debug optimized build (not a Release build).
@nvlsianpu
We are getting a number of Compiler Warnings when building Zephyr 1.14 (See below).
The variable rc is not initialized in these functions and could potentially get returned without being set to a value. In actual fact it may not be possible for this to happen due to the values passed into these functions being correct, but the Compiler cannot determine this, and it would be safer to actively prevent this possibility in the functions themselves.
Can you please advise on the best way to correct these warnings?
It seems that simply initializing the rc variables to an invalid value when they are declared would achieve this - do you agree?
Regards,
Declan Traill
Setec Pty Ltd
[50/254] Building C object zephyr/CMakeFiles/zephyr.dir/subsys/settings/src/settings_store.c.obj
C:/Users/declan.traill/RVMN101/zephyr/subsys/settings/src/settings_store.c: In function 'settings_cmp':
C:/Users/declan.traill/RVMN101/zephyr/subsys/settings/src/settings_store.c:113:9: warning: 'rc' may be used uninitialized in this function [-Wmaybe-uninitialized]
return rc;
^~
[52/254] Building C object zephyr/CMakeFiles/zephyr.dir/subsys/settings/src/settings_line.c.obj
C:/Users/declan.traill/RVMN101/zephyr/subsys/settings/src/settings_line.c: In function 'settings_line_raw_read_until':
C:/Users/declan.traill/RVMN101/zephyr/subsys/settings/src/settings_line.c:272:19: warning: 'rc' may be used uninitialized in this function [-Wmaybe-uninitialized]
return (rc) ? 0 : 1;
~~~~~~~~~^~~
C:/Users/declan.traill/RVMN101/zephyr/subsys/settings/src/settings_line.c: In function 'settings_entry_copy':
C:/Users/declan.traill/RVMN101/zephyr/subsys/settings/src/settings_line.c:444:9: warning: 'rc' may be used uninitialized in this function [-Wmaybe-uninitialized]
return rc;
^~
[55/254] Building C object zephyr/CMakeFiles/zephyr.dir/subsys/settings/src/settings_fcb.c.obj
C:/Users/declan.traill/RVMN101/zephyr/subsys/settings/src/settings_fcb.c: In function 'settings_fcb_save':
C:/Users/declan.traill/RVMN101/zephyr/subsys/settings/src/settings_fcb.c:270:5: warning: 'rc' may be used uninitialized in this function [-Wmaybe-uninitialized]
if (rc) {
^
The text was updated successfully, but these errors were encountered: