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

[Coverity CID :206018] Side effect in assertion in tests/kernel/sched/metairq/src/main.c #20966

Closed
zephyrbot opened this issue Nov 25, 2019 · 0 comments · Fixed by #20985
Closed
Assignees
Labels
bug The issue is a bug, or the PR is fixing a bug Coverity A Coverity detected issue or its fix priority: low Low impact/importance bug

Comments

@zephyrbot
Copy link
Collaborator

Static code scan issues found in file:

https://github.com/zephyrproject-rtos/zephyr/tree/7aa2355af2d8b735351c5def9495e40e453c749b/tests/kernel/sched/metairq/src/main.c#L75

Category: Incorrect expression
Function: coop_thread1
Component: Tests
CID: 206018

Details:

69     {
70         k_sem_take(&coop_sem1, K_FOREVER);
71    
72         /* Expect that low-priority thread has run to completion */
73         zassert_equal(coop_cnt1, 0,
74                   "Unexpected cnt1 at start: %d", coop_cnt1);
>>>     CID 206018:  Incorrect expression  (ASSERT_SIDE_EFFECT)
>>>     Argument "coop_cnt2" of z_zassert() has a side effect because the variable is volatile.  The containing function might work differently in a non-debug build.
75         zassert_equal(coop_cnt2, LOOP_CNT,
76                   "Unexpected cnt2 at start: %d", coop_cnt2);
77    
78         printk("thread1\n");
79         coop_cnt1++;
80    

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.

@zephyrbot zephyrbot added bug The issue is a bug, or the PR is fixing a bug Coverity A Coverity detected issue or its fix priority: low Low impact/importance bug labels Nov 25, 2019
aescolar added a commit to aescolar/zephyr that referenced this issue Nov 25, 2019
Coverity's analysis is not happy about using a volatile variable
in an assert, even if the assert is not optionally compiled in.
Avoid the issue by loading the value in an automatic varible before
using it in the assert.

CID: 206016
CID: 206018
CID: 206019
CID: 206021
Fixes: zephyrproject-rtos#20968
Fixes: zephyrproject-rtos#20966
Fixes: zephyrproject-rtos#20965
Fixes: zephyrproject-rtos#20963

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
nashif pushed a commit that referenced this issue Nov 25, 2019
Coverity's analysis is not happy about using a volatile variable
in an assert, even if the assert is not optionally compiled in.
Avoid the issue by loading the value in an automatic varible before
using it in the assert.

CID: 206016
CID: 206018
CID: 206019
CID: 206021
Fixes: #20968
Fixes: #20966
Fixes: #20965
Fixes: #20963

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue is a bug, or the PR is fixing a bug Coverity A Coverity detected issue or its fix priority: low Low impact/importance bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants