<noreturn>true</noreturn> is parsed, but produces the same output as before: "Either the condition is redundant or there is possible null pointer dereference".
<noreturn>false</noreturn> also produces the same output (as expected).
"--check-library" shows that it's definitely picking up the rte_panic def from the config file.
(Using cppcheck @ a7707a457)
Last edit: Paul Aitken 2021-06-14
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
could you give an example code that reproduce the problem
danielm@debian:~/cppcheck$./cppcheck--enable=style1.cChecking1.c...1.c:2:5:error:syntaxerror:keyword'if'isnotallowedinglobalscope[syntaxError]if(!ptr){^danielm@debian:~/cppcheck$cat1.cptr=fn();if(!ptr){rte_panic("couldn't get ptr");}dostuff(ptr->member,foo,bar);
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
cppcheck doesn't understand that rte_panic terminates execution, so given code like below, "cppcheck --enable=warning" warns:
"Either the condition '!ptr' is redundant or there is possible null pointer dereference: ptr."
This is not reported if a "return" is added under the rte_panic.
you can fix that with a configuration file. a start (untested):
Thanks Daniel.
<noreturn/>
segfaulted.<noreturn>true</noreturn>
is parsed, but produces the same output as before: "Either the condition is redundant or there is possible null pointer dereference".<noreturn>false</noreturn>
also produces the same output (as expected)."--check-library" shows that it's definitely picking up the rte_panic def from the config file.
(Using cppcheck @ a7707a457)
Last edit: Paul Aitken 2021-06-14
Any more thoughts on this, @danielmarjamaki ?
could you give an example code that reproduce the problem
.. and when I try to fill in some code I don't get the false positive.
@danielmarjamaki, use "cppcheck --enable=warning".
For example:
Since rte_panic doesn't return, a null pointer can never be dereferenced.
This works:
<arg nr="all"/>
doesn't work.<noreturn/>
segfaults.it looks like rte_panic takes a format string..
That solves the false positive for me.
That's even better, thanks @danielmarjamaki.
Would you add that to one of the existing cfg files, or start a new one for DPDK APIs?
I would probably create a new dpdk.cfg file.. if you create that and share it with me I will add it in Cppcheck.
Thanks @danielmarjamaki.
See https://github.com/danmar/cppcheck/pull/3313