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.73k stars 6.55k forks source link

[Coverity CID :210601] Incompatible cast in tests/lib/cmsis_dsp/fastmath/src/f32.c #25768

Closed zephyrbot closed 4 years ago

zephyrbot commented 4 years ago

Static code scan issues found in file:

https://github.com/zephyrproject-rtos/zephyr/tree/4653b4e63f886a50ac7b72f8d47ba2950ab2dd0d/tests/lib/cmsis_dsp/fastmath/src/f32.c#L71

Category: Integer handling issues Function: test_arm_sin_f32 Component: Tests CID: 210601

Details:

60         /* Run test function */
61         for (index = 0; index < length; index++) {
62             output[index] = arm_sin_f32(((float32_t *)in_angles)[index]);
63         }
64    
65         /* Validate output */
>>>     CID 210601:    (INCOMPATIBLE_CAST)
>>>     Pointer "ref_sin" points to an object whose effective type is "unsigned int" (integral) but is dereferenced as a "float" (floating point). The cast will not convert the value of the object.
66         zassert_true(
67             test_snr_error_f32(length, output, (float32_t *)ref_sin,
68                 SNR_ERROR_THRESH),
69             ASSERT_MSG_SNR_LIMIT_EXCEED);
70    
71         zassert_true(
65         /* Validate output */
66         zassert_true(
67             test_snr_error_f32(length, output, (float32_t *)ref_sin,
68                 SNR_ERROR_THRESH),
69             ASSERT_MSG_SNR_LIMIT_EXCEED);
70    
>>>     CID 210601:    (INCOMPATIBLE_CAST)
>>>     Pointer "ref_sin" points to an object whose effective type is "unsigned int" (integral) but is dereferenced as a "float" (floating point). The cast will not convert the value of the object.
71         zassert_true(
72             test_close_error_f32(length, output, (float32_t *)ref_sin,
73                 ABS_ERROR_THRESH, REL_ERROR_THRESH),
74             ASSERT_MSG_ERROR_LIMIT_EXCEED);
75    
76         /* Free output buffer */

Please fix or provide comments in coverity using the link:

https://scan9.coverity.com/reports.htm#v32951/p12996.

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 CODEOWNERS file.

stephanosio commented 4 years ago

Intentional-Ignore

For more details, refer to the Coverity history.