79276155

Date: 2024-12-12 18:16:40
Score: 0.5
Natty:
Report link

Klocwork checker NUM.OVERFLOW.DF can report the issue if there are possible cases of numeric overflow or wraparound in an arithmetic operation.

When performing subtraction (e.g., Coord1 - Coord2), no negative values are allowed in unsigned arithmetic. If Coord2 is greater than Coord1, the subtraction will result in a wraparound (underflow), leading to unexpected large values. uint16 is an unsigned 16-bit integer with a range of 0 to 65535. in this case i believe the Static code analysis tool you are using (Klocwork) has reported a valid issue.

To resolve this, you may consider to cast the uint16 variables to a signed type (e.g., int32) during the subtraction to ensure that underflow doesn't occur, then convert back if necessary.

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (0.5):
Posted by: Sivanesh Waran