-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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 :219662] Inequality comparison against NULL in lib/os/cbprintf_packaged.c #33027
Comments
This code looks very similar: https:/zephyrproject-rtos/zephyr/blob/master/subsys/logging/log_core.c#L116 could the slight differences between For example in log_core.c we have: #if defined(CONFIG_ARM) || defined(CONFIG_ARC) || defined(CONFIG_X86)
extern const char *_image_rodata_start[];
extern const char *_image_rodata_end[];
#define RO_START _image_rodata_start
#define RO_END _image_rodata_end
But this function in #elif defined(CONFIG_ARC) || defined(CONFIG_ARM) || defined(CONFIG_X86) \
|| defined(CONFIG_RISCV)
extern char _image_rodata_start[];
extern char _image_rodata_end[];
#define RO_START _image_rodata_start
#define RO_END _image_rodata_end I am specifically wondering about this part: |
On Thu, 11 Mar 2021, Guðni Már Gilbert wrote:
I am specifically wondering about this part: `extern const char *` <--> `extern char`
Adding a `const` certainly won't hurt.
In any case, this would gain to be made into some per-architecture
abstraction common to all users.
|
This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time. |
This is false positive. The coverity does not understand what is happening there: it thinks that the comparison is to detect whether addr has valid (non-NULL) or invalid (NULL) pointer. Because it sees that RO_START is 0 (NULL), it thinks that someone is trying to check if addr is NULL or not, and does not understand that it is basically test if addr fits in specific range, which is given by [RO_START,RO_END) @npitre do you agree? |
Static code scan issues found in file:
https:/zephyrproject-rtos/zephyr/tree/bd97359a5338b2542d19011b6d6aa1d8d1b9cc3f/lib/os/cbprintf_packaged.c#L54
Category: Incorrect expression
Function:
ptr_in_rodata
Component: Other
CID: 219662
Details:
https:/zephyrproject-rtos/zephyr/blob/bd97359a5338b2542d19011b6d6aa1d8d1b9cc3f/lib/os/cbprintf_packaged.c
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.
The text was updated successfully, but these errors were encountered: