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

Compiler warnings in settings module in Zephyr 1.14 #17031

Closed
DeclanTraill opened this issue Jun 25, 2019 · 4 comments
Closed

Compiler warnings in settings module in Zephyr 1.14 #17031

DeclanTraill opened this issue Jun 25, 2019 · 4 comments
Assignees
Labels
bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug
Milestone

Comments

@DeclanTraill
Copy link
Contributor

@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) {
^

@DeclanTraill DeclanTraill added the bug The issue is a bug, or the PR is fixing a bug label Jun 25, 2019
@ioannisg ioannisg added this to the v1.14.1 milestone Jun 25, 2019
@ioannisg ioannisg added the priority: low Low impact/importance bug label Jun 25, 2019
@ioannisg
Copy link
Member

@DeclanTraill do we get the same warnings in master?

@DeclanTraill
Copy link
Contributor Author

@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).

@ioannisg
Copy link
Member

Thanks! If you see warnings in master, pls, could you open a separate issue?

@nvlsianpu
Copy link
Collaborator

Was fixed in #16078

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug
Projects
None yet
Development

No branches or pull requests

3 participants