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 :211045] Macro compares unsigned to 0 in kernel/timeout.c #26355

Closed
zephyrbot opened this issue Jun 23, 2020 · 3 comments · Fixed by #27591
Closed

[Coverity CID :211045] Macro compares unsigned to 0 in kernel/timeout.c #26355

zephyrbot opened this issue Jun 23, 2020 · 3 comments · Fixed by #27591
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/8e2c4a475dc375da6691175dd1da87525053ed76/kernel/timeout.c#L112

Category: Integer handling issues
Function: z_add_timeout
Component: Kernel
CID: 211045

Details:

106    
107         LOCKED(&timeout_lock) {
108             struct _timeout *t;
109    
110             to->dticks = ticks + elapsed();
111             for (t = first(); t != NULL; t = next(t)) {
>>>     CID 211045:  Integer handling issues  (NO_EFFECT)
>>>     This greater-than-or-equal-to-zero comparison of an unsigned value is always true. "t->dticks >= 0ULL".
112                 __ASSERT(t->dticks >= 0, "");
113    
114                 if (t->dticks > to->dticks) {
115                     t->dticks -= to->dticks;
116                     sys_dlist_insert(&t->node, &to->node);
117                     break;

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 Jun 23, 2020
@dleach02
Copy link
Member

@andyross, This assert doesn't make sense? Do you know what the intent was? Was dticks once a signed value?

@andrewboie
Copy link
Contributor

is this an artifact when time values used to be signed?

@dleach02
Copy link
Member

dticks used to be unsigned so likely a left over. I'll add a fix to my PR I'm putting together to clean up these coverity issues

nashif pushed a commit that referenced this issue Aug 16, 2020
The dticks field was changed from a signed to an unsigned
value so now the assert test to ensure it isn't negative
is no longer needed.

fixes #26355

Signed-off-by: David Leach <david.leach@nxp.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