in my cppcheck1.70 results I have two findings that I'd like to ignore (copied from the output of the Jenkins cppcheck plugin):
/src/tsd.system.displaymanager/src/tsd/system/displaymanager/lin/EGLDisplayClientLinux.cpp 104 style duplicateBranch Found duplicate branches for 'if' and 'else'.
/src/tsd.system.displaymanager/src/tsd/system/displaymanager/qnxscreen/EventReceiver.cpp 258 warning nullPointerRedundantCheck Either the condition '0==screenShot' is redundant or there is possible null pointer dereference: screenShot.
I wanted to ignore these with a suppression file with the following entries:
Findings of other checkers have successfully been ignored (with other lines in the suppression file); but all findings of the checkers mentioned above have not been ignored.
Printing the cppcheck1.70 --errorlist I can't find the duplicateBranch checker, but the nullPointerRedundantCheck checker.
Addition: the problem also exists (at least) for the checkers:
duplicateBranch
variableHidingEnum
nullPointerRedundantCheck
syntaxError
variableHidingTypedef
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The checkers does not know if warnings are suppressed. When the warning is generated by the checker, the suppression will block it from being displayed.
Therefore it is very confusing to me that these particular warnings can't be suppressed, while others can.
Does this little example work for you?
void f(int *p) {
*p = 0;
if (!p) {}
}
When I run Cppcheck on that it reports:
$ ./cppcheck --enable=warning 1.c
Checking 1.c...
[1.c:2] -> [1.c:3]: (warning) Either the condition '!p' is redundant or there is possible null pointer dereference: p.
C:\Program Files\Cppcheck1_70>cppcheck.exe --enable=warning --suppress=nullPointerRedundantCheck:1.c:3 c:\Users\martin.meyer\Desktop\1.c
Checking c:\Users\martin.meyer\Desktop\1.c... [c:\Users\martin.meyer\Desktop\1.c:2] -> [c:\Users\martin.meyer\Desktop\1.c:3]: (warning) Either the condition '!p' is redundant or there is possible null pointer dereference: p.
C:\Program Files\Cppcheck1_70>cppcheck.exe --enable=warning --suppress=nullPointerRedundantCheck:1.c:2 c:\Users\martin.meyer\Desktop\1.c
Checking c:\Users\martin.meyer\Desktop\1.c... [c:\Users\martin.meyer\Desktop\1.c:2] -> [c:\Users\martin.meyer\Desktop\1.c:3]: (warning) Either the condition '!p' is redundant or there is possible null pointer dereference: p.
In the Trac ticket 7080 I listed a code file with a number of issues that I wasn't able to suppress (code file + suppression file + output text).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
in my cppcheck1.70 results I have two findings that I'd like to ignore (copied from the output of the Jenkins cppcheck plugin):
/src/tsd.system.displaymanager/src/tsd/system/displaymanager/lin/EGLDisplayClientLinux.cpp 104 style duplicateBranch Found duplicate branches for 'if' and 'else'.
/src/tsd.system.displaymanager/src/tsd/system/displaymanager/qnxscreen/EventReceiver.cpp 258 warning nullPointerRedundantCheck Either the condition '0==screenShot' is redundant or there is possible null pointer dereference: screenShot.
I wanted to ignore these with a suppression file with the following entries:
duplicateBranch:/tsd.system.displaymanager/src/tsd/system/displaymanager/lin/EGLDisplayClientLinux.cpp:104
nullPointerRedundantCheck:/tsd.system.displaymanager/src/tsd/system/displaymanager/qnxscreen/EventReceiver.cpp:258
The output of a cppcheck1.70 run with this suppression file used contains:
[*\tsd.system.displaymanager\src\tsd\system\displaymanager\lin\EGLDisplayClientLinux.cpp:104]: (information) Unmatched suppression: duplicateBranch
[*\tsd.system.displaymanager\src\tsd\system\displaymanager\qnxscreen\EventReceiver.cpp:258]: (information) Unmatched suppression: nullPointerRedundantCheck
Findings of other checkers have successfully been ignored (with other lines in the suppression file); but all findings of the checkers mentioned above have not been ignored.
Printing the cppcheck1.70 --errorlist I can't find the duplicateBranch checker, but the nullPointerRedundantCheck checker.
How can this be explained?
Thanks in advance,
Martin
Addition: the problem also exists (at least) for the checkers:
duplicateBranch
variableHidingEnum
nullPointerRedundantCheck
syntaxError
variableHidingTypedef
Weird!
The checkers does not know if warnings are suppressed. When the warning is generated by the checker, the suppression will block it from being displayed.
Therefore it is very confusing to me that these particular warnings can't be suppressed, while others can.
Does this little example work for you?
When I run Cppcheck on that it reports:
To suppress the warning I use line number "3":
If I use line number "2" the warning is not suppressed.
Neither 2 nor 3 as line number work for me:
C:\Program Files\Cppcheck1_70>cppcheck.exe --enable=warning --suppress=nullPointerRedundantCheck:1.c:3 c:\Users\martin.meyer\Desktop\1.c
Checking c:\Users\martin.meyer\Desktop\1.c...
[c:\Users\martin.meyer\Desktop\1.c:2] -> [c:\Users\martin.meyer\Desktop\1.c:3]: (warning) Either the condition '!p' is redundant or there is possible null pointer dereference: p.
C:\Program Files\Cppcheck1_70>cppcheck.exe --enable=warning --suppress=nullPointerRedundantCheck:1.c:2 c:\Users\martin.meyer\Desktop\1.c
Checking c:\Users\martin.meyer\Desktop\1.c...
[c:\Users\martin.meyer\Desktop\1.c:2] -> [c:\Users\martin.meyer\Desktop\1.c:3]: (warning) Either the condition '!p' is redundant or there is possible null pointer dereference: p.
In the Trac ticket 7080 I listed a code file with a number of issues that I wasn't able to suppress (code file + suppression file + output text).
hi sorry for late reply.
As you probably know.. the warning is not suppressed in any file with the name 1.c. the path must match.
This works right?
Thanks for creating ticket 7080. We can try to continue the discussion there.
Last edit: Daniel Marjamäki 2015-11-06