Menu

Problem with ignoring issues in Cppcheck1.70

Martin
2015-10-27
2015-11-06
  • Martin

    Martin - 2015-10-27

    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

     
  • Martin

    Martin - 2015-10-27

    Addition: the problem also exists (at least) for the checkers:
    duplicateBranch
    variableHidingEnum
    nullPointerRedundantCheck
    syntaxError
    variableHidingTypedef

     
  • Daniel Marjamäki

    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?

    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.
    

    To suppress the warning I use line number "3":

    $ ./cppcheck --enable=warning --suppress=nullPointerRedundantCheck:1.c:3 1.c
    

    If I use line number "2" the warning is not suppressed.

     
    • Martin

      Martin - 2015-11-03

      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).

       
  • Daniel Marjamäki

    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?

    $ cd c:\Users\martin.meyer\Desktop
    $ C:\Program Files\Cppcheck1_70\cppcheck.exe --enable=warning --suppress=nullPointerRedundantCheck:1.c:3 1.c
    

    Thanks for creating ticket 7080. We can try to continue the discussion there.

     

    Last edit: Daniel Marjamäki 2015-11-06

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.