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 :208406] Macro compares unsigned to 0 in subsys/net/l2/ppp/ppp_l2.c #22912

Closed
zephyrbot opened this issue Feb 18, 2020 · 0 comments · Fixed by #23017
Closed

[Coverity CID :208406] Macro compares unsigned to 0 in subsys/net/l2/ppp/ppp_l2.c #22912

zephyrbot opened this issue Feb 18, 2020 · 0 comments · Fixed by #23017
Assignees
Labels
area: Networking 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/93b78b7bf8bfad75196de969a7487f95f235aad3/subsys/net/l2/ppp/ppp_l2.c#L346

Category: Integer handling issues
Function: echo_reply_handler
Component: Networking
CID: 208406

Details:

340     static void echo_reply_handler(void *user_data, size_t user_data_len)
341     {
342         struct ppp_context *ctx = user_data;
343         u32_t end_time = k_cycle_get_32();
344         int time_diff;
345    
>>>     CID 208406:  Integer handling issues  (NO_EFFECT)
>>>     This less-than-zero comparison of an unsigned value is never true. "end_time - ctx->shell.echo_req_data < 0U".
346         time_diff = abs(end_time - ctx->shell.echo_req_data);
347         ctx->shell.echo_req_data =
348             k_cyc_to_ns_floor64(time_diff) / 1000;
349    
350         k_sem_give(&ctx->shell.wait_echo_reply);
351     }

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 Feb 18, 2020
rveerama1 added a commit to rveerama1/zephyr that referenced this issue Feb 21, 2020
Store the time difference value in u32_t variable than
abs() value in signed variable.

Fixes zephyrproject-rtos#22912
Coverity CID: 208406

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
@rveerama1 rveerama1 assigned rveerama1 and unassigned jukkar and tbursztyka Feb 21, 2020
ioannisg pushed a commit that referenced this issue Feb 25, 2020
Store the time difference value in u32_t variable than
abs() value in signed variable.

Fixes #22912
Coverity CID: 208406

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Networking 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