ARM-software / CMSIS-DSP

CMSIS-DSP embedded compute library for Cortex-M and Cortex-A
https://arm-software.github.io/CMSIS-DSP
Apache License 2.0
454 stars 122 forks source link

CppCheck giving warning for arm_divide_q31 because of CWE 758 violation #165

Closed marcluque closed 3 months ago

marcluque commented 4 months ago

I encountered a warning from CppCheck indicating the the following line of arm_divide_q31.c#L66 is violating CWE 758. CppCheck message:

cppcheck version="2.5"
msg="Shifting signed 32-bit value by 31 bits is implementation-defined behaviour"
cwe="758"

This will also hold for q15 I think.

I suppose that something like (numerator < 0) ^ (denominator < 0) could fix it?

christophe0606 commented 3 months ago

Corrected in latest commit

marcluque commented 3 months ago

Very nice, thanks for the quick turnaround! I'll close this issue then.