Skip to content

Conversation

@moonlight83340
Copy link
Contributor

Coverity reports a potential integer overflow in the accel_range computation due to the use of a left shift on an int type.

CID 520269: Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN)

Even though the register value is constrained to 0–3 by the BMA456 spec, and no real overflow occurs, an explicit cast to int64_t prevents false positives and aligns with safe coding practices.

Fixes: #90517

@moonlight83340 moonlight83340 marked this pull request as ready for review July 2, 2025 05:01
@github-actions github-actions bot added area: Sensors Sensors size: XS A PR changing only a single line of code labels Jul 2, 2025
MaureenHelm
MaureenHelm previously approved these changes Jul 2, 2025
Coverity reports a potential integer overflow in the accel_range
computation due to the use of a left shift on an int type.

CID 520269: Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN)

Even though the register value is constrained to 0–3 by the BMA456 spec,
and no real overflow occurs, an explicit cast to int64_t prevents false
positives and aligns with safe coding practices.

Fixes: zephyrproject-rtos#90517

Signed-off-by: Gaetan Perrot <[email protected]>
@sonarqubecloud
Copy link

sonarqubecloud bot commented Jul 3, 2025

@danieldegrasse danieldegrasse merged commit 9207749 into zephyrproject-rtos:main Jul 4, 2025
26 checks passed
@moonlight83340 moonlight83340 deleted the Coverity_CID_520269 branch July 9, 2025 05:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: Sensors Sensors size: XS A PR changing only a single line of code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Coverity CID: 520269] Unintentional integer overflow in drivers/sensor/bosch/bma4xx/bma4xx_emul.c

5 participants