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: 219729] Logically dead code in lib/os/cbprintf_packaged.c #33311

Closed
zephyrbot opened this issue Mar 13, 2021 · 1 comment
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/b4f5b9e23770f2c9cddf95fef7b9af32da309f7f/lib/os/cbprintf_packaged.c#L379

Category: Control flow issues
Function: cbvprintf_package
Component: Other
CID: 219729

Details:

return -EFAULT;

373    
374             /* align destination buffer location */
375             buf = (void *) ROUND_UP(buf, align);
376    
377             /* Check if buffer is properly aligned. */
378             if ((uintptr_t)buf0 & (align - 1)) {
>>>     CID 219729:  Control flow issues  (DEADCODE)
>>>     Execution cannot reach this statement: "return -14;".
379                 return -EFAULT;
380             }
381    
382             /* make sure the data fits */
383             if (buf0 && buf - buf0 + size > len) {
384                 return -ENOSPC;

Please fix or provide comments in coverity using the link:

https://scan9.coverity.com/reports.htm#v29271/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 Mar 13, 2021
@npitre
Copy link
Collaborator

npitre commented Mar 13, 2021

This report should be ignored.

The coverity link also gives me a 401.

Here the dead code is dead only on some architectures like x86 where the
alignment is hardcoded to 1. In this case the compiler should rightfully
optimize the dead code away. With other configurations, that code has its
purpose.

@npitre npitre closed this as completed Mar 13, 2021
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

No branches or pull requests

2 participants