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

Issues with ternary operator & operator precedence in Cordio #801

Closed
sullivanmj opened this issue Nov 20, 2023 · 2 comments · Fixed by #803
Closed

Issues with ternary operator & operator precedence in Cordio #801

sullivanmj opened this issue Nov 20, 2023 · 2 comments · Fixed by #803
Labels
BLE Related to Bluetooth bug Something isn't working

Comments

@sullivanmj
Copy link

I was running a static code analyzer on my project and it produced warnings that there are a few places in Cordio where there may be some bugs due to the ternary operator ?: having a lower precedence than the addition operator +.

In each of these cases, the ternary operator should looks like it should be evaluated before the addition operator, but it is not.

https://github.com/Analog-Devices-MSDK/msdk/blob/4461e6d6383ac7e31285534e4e4e1a87531e5baf/Libraries/Cordio/controller/sources/ble/lctr/lctr_main_conn.c#L1568

https://github.com/Analog-Devices-MSDK/msdk/blob/4461e6d6383ac7e31285534e4e4e1a87531e5baf/Libraries/Cordio/controller/sources/ble/lctr/lctr_main_adv_master_ae.c#L1307

https://github.com/Analog-Devices-MSDK/msdk/blob/4461e6d6383ac7e31285534e4e4e1a87531e5baf/Libraries/Cordio/controller/sources/ble/lctr/lctr_int_adv_master_ae.h#L477

@Jake-Carter Jake-Carter added BLE Related to Bluetooth bug Something isn't working labels Nov 21, 2023
@Jake-Carter
Copy link
Contributor

Thanks @sullivanmj, I've just opened a PR to add some extra parenthesis.

Let us know if your analyzer uncovers anything else

@sullivanmj
Copy link
Author

No problem - that was the only thing it uncovered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BLE Related to Bluetooth bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants