-
Notifications
You must be signed in to change notification settings - Fork 8.3k
drivers: modem: fix uninitialized variable warnings in modem_stats #81431
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
drivers: modem: fix uninitialized variable warnings in modem_stats #81431
Conversation
tomi-font
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No?
|
I mean, did you actually get some error because of those? The one at line 113 would be very surprising as |
You are right about line 113, but I encountered the following errors during compilation: /home/fk/Dokumente/workspace/modular_nrf/zephyr/subsys/modem/modem_stats.c:41:16: error: 'first' may be used uninitialized [-Werror=maybe-uninitialized] These errors were produced using arm-zephyr-eabi-gcc targeting a Cortex-M33 MCU, with the -Werror flag treating warnings as errors. Given that Zephyr supports many different toolchains and optimization settings, I believe it's safer to explicitly initialize these variables to NULL to prevent similar warnings for other developers using different compiler settings. |
6029ae0 to
000b740
Compare
The variables 'first' and 'next' in function 'stats_buffer_list_first()' and 'stats_buffer_list_next()' were potentially used uninitialized. Depending on the compiler and target architecture, this can lead to different behavior, including warnings or errors when using strict warning flags. By initializing these pointers to 'NULL', we ensure consistent and expected behavior across all toolchains and configurations. Signed-off-by: Fabian Kainka <[email protected]>
000b740 to
cf854bf
Compare
tomi-font
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah you're right. Thanks for the fix!
|
The only reason I can see for any compiler to complain here is that it can't understand the |
This PR is related to the following Zephyr PR: zephyrproject-rtos#81431 Some compilers (e.g. arm-zephyr-eabi-gcc) don't understand the K_SPINLOCK() macro and therefore do warn about uninitialized variables in the modem related modules. Signed-off-by: Fabian Kainka <[email protected]>
…needed This PR is related to the following Zephyr PR: zephyrproject-rtos#81431 Some compilers (e.g. arm-zephyr-eabi-gcc) don't understand the K_SPINLOCK() macro and therefore do warn about uninitialized variables in the modem related modules. Fix: Replaced the K_SPINLOCK macro with explicit k_spin_lock/k_spin_unlock calls only at relevant locations in the modem subsystem. Signed-off-by: Fabian Kainka <[email protected]>
The variables 'first' and 'next' in the functions 'stats_buffer_list_first()' and
'stats_buffer_list_next()' were potentially used uninitialized. Depending on the
compiler and target architecture, this can lead to different behavior, including
warnings or errors when using strict warning flags. By initializing these pointers
to 'NULL', we ensure consistent and expected behavior across all toolchains and
architectures.
Signed-off-by: Fabian Kainka [email protected]