-
Notifications
You must be signed in to change notification settings - Fork 1.3k
libnml: Fixed memleak in configuration parsing #3701
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
Conversation
|
Instead of suppressing the cppcheck uninitialized warning, it may be appropriate just to initialize the double p1[9], p2[9], pl[9] = {};No comment on the mem-leak :-) |
I would like to keep the suppression as a reminder that the code is a bit tricky to read. Also, erroneously assigning a default value 0 or undefined is equally unfortunate, so the suppression is something like a quick statement that the devs are aware of the situation.
:) |
Tricky,... that is an understatement.
That is not necessarily a problem. The real problem is that cppcheck cannot perform the correct analysis. The code and compound condition makes The cppcheck message is a false positive. If you suppress the message, then you should at least precede it with a comment why the message needs to be suppressed. That would help to understand the "tricky" code a bit better ;-) |
| if(first || memcmp(p1, pl, sizeof(p1)) | ||
|
|
||
| // cppcheck-suppress uninitvar | ||
| if(first || memcmp(p1, pl, sizeof(p1)) // <- since first==1 when pl undefined |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here the explanation is given why the cppcheck error is suppressed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry to be a nitpick here...
The comment is usually added before the suppress with a reference to the suppress.
// Suppress cppcheck false positive: 'first' == 1 when 'pl' is undefined and therefore not a problem
// cppcheck-suppress uninitvarf67604e to
63ab861
Compare
Also suppressing false positive report on use of undefined variable.
Also suppressing false positive report on use of undefined variable.