zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.99k stars 6.69k forks source link

[Coverity CID: 434524] 'Constant' variable guards dead code in subsys/bluetooth/host/conn.c #81984

Open zephyrbot opened 6 days ago

zephyrbot commented 6 days ago

Static code scan issues found in file:

https://github.com/zephyrproject-rtos/zephyr/tree/b1def7145fd/subsys/bluetooth/host/conn.c

Category: Possible Control flow issues Function: can_initiate_feature_exchange Component: Bluetooth CID: 434524

Details:

https://github.com/zephyrproject-rtos/zephyr/blob/b1def7145fd/subsys/bluetooth/host/conn.c#L1727

Please fix or provide comments in coverity using the link:

https://scan9.scan.coverity.com/#/project-view/29271/12996?selectedIssue=434524

For more information about the violation, check the Coverity Reference. (CWE-561)

Note: This issue was created automatically. Priority was set based on classification of the file affected and the impact field in coverity. Assignees were set using the MAINTAINERS file.

jhedberg commented 6 days ago

This is a false positive, but maybe we can improve the situation a bit. Coverity is saying

"Local variable onboard_controller is assigned only once, to a constant value, making it effectively constant throughout its scope. If this is not the intent, examine the logic to see if there is a missing assignment that would make onboard_controller not remain constant."

Declaring the variable as const bool instead of bool might make this warning go away. @alwa-nordic @jori-nordic any thoughts?