Menu

Cppcheck and MISRA C 2012 rules doesn't return any messages?

2020-01-21
2020-01-27
  • Richard Bamford

    Richard Bamford - 2020-01-21

    Hi,

    I've been trying to get Cppcheck working all day, i've had moderate success using it as a command line tool but the GUI utility just doesn't seem to work correctly.

    I have the MISRA C 2012 standard and have set up a temporary MISRA texts file to run against my code before i commit to writing all the information in.

    In the result of my analysis using a .vcprojx and setting the MISRA ruleset up to the right path, i receive these error messages?

    "C:\Users\Richa\Documents\GitHub\Remote-Train-Sensor\SAIN Software - Visual Micro\SAINSoftware\SAINSoftware\src\Interface_GPS.cpp - symbolDatabaseWarning - debug
    Executable scope 'Initialize' with unknown function.
    Executable scope 'Initialize' with unknown function.
    C:\Users\Richa\Documents\GitHub\Remote-Train-Sensor\SAIN Software - Visual Micro\SAINSoftware\SAINSoftware\src\Interface_GPS.cpp: 7"

    "C:\Users\Richa\Documents\GitHub\Remote-Train-Sensor\SAIN Software - Visual Micro\SAINSoftware\SAINSoftware\src\Interface_SD.cpp - valueFlowBailout - debug
    valueflow.cpp:6232:ValueFlowConditionHandler::afterCondition bailout: valueFlowAfterCondition: rootFile is changed in conditional block
    valueflow.cpp:6232:ValueFlowConditionHandler::afterCondition bailout: valueFlowAfterCondition: rootFile is changed in conditional block
    C:\Users\Richa\Documents\GitHub\Remote-Train-Sensor\SAIN Software - Visual Micro\SAINSoftware\SAINSoftware\src\Interface_SD.cpp: 247"

    I get one of these for each file in my project however the .vcprojx file contains all the headers and source files required, also no MISRA guidelines are reported when there should be a few in the list? Only the normal Cppcheck ones show up, no MISRA ones?

    Any help would be great!
    Thanks,
    Richard

     

    Last edit: Richard Bamford 2020-01-21
  • Daniel Marjamäki

    In the gui, can you please configure a "Cppcheck build dir" in the project settings. It's in the second tab "Checking".

    After an analysis the build folder should contain files. If you open the folder what files do you see?

    For each source file you have there should be both a "dump" and "dump-misra-results" file.

     
  • Daniel Marjamäki

    hmm.. I can see a problem also when I test it in the GUI. At least with latest git HEAD.

     
  • Daniel Marjamäki

    hmm.. I can see a problem also when I test it in the GUI. At least with latest git HEAD.

    No my mistake. I made a simple mistake. I had hidden the "style" warnings. For me, misra warnings are shown in the GUI.. and it should work for you also.

     
  • Richard Bamford

    Richard Bamford - 2020-01-22

    hi, i think it might be because my project is using a different platform and also c++, https://www.visualmicro.com/

    But should it be compatable with any vc++ project type?

     

    Last edit: Richard Bamford 2020-01-22
  • Daniel Marjamäki

    do you get any .dump files in your cppcheck build dir? do you get .dump-misra-results files?

    as far as I know you can run it with any vc++ project type.. but I have not tried visualmicro. If it's not compatible then you probably don't get the expected .dump files.

     
  • Richard Bamford

    Richard Bamford - 2020-01-22

    it did generate the raw dump files which were correct and a MISRA dump file which was empty. I'm now running this on my OS X laptop and the command line works flawlessly.

     
  • Richard Bamford

    Richard Bamford - 2020-01-22

    It seems like when i point Cppcheck to the MISRA.txt file, it breaks the usual preprocessing?

    edit -
    When i use a MISRA.txt file that doesn't contain anything but the rule numbers, the misra.py script runs correctly (finds the violations correct) but when it can't process the MISRA.txt it doesn't throw an error it glitches out and doesn't work properly.

    edit -
    Commands used:
    "cppcheck -Iheaders src --dump"
    "cppcheck --addon=misra.json src"

    misra.json:
    {
    "script": "misra.py",
    "args":
    "--rule-texts=/Users/richardbamford/Documents/xxx/xxx/MISRA/MISRA_C_2012.txt"

    }

    MISRA_C_2012.txt contents (just rule numbers):
    https://pastebin.com/Rwk1Mfx2

    Result:

    (cppcheck -Iheaders src --dump)
    https://pastebin.com/BjiiAg83

    (cppcheck --addon=misra.json src)
    https://pastebin.com/NuBvrSQb

    In the output, rule text is not added see: "use --rule-texts=<file> to get proper output" in summary.</file>

     

    Last edit: Richard Bamford 2020-01-22
    • versat

      versat - 2020-01-27

      When i use a MISRA.txt file that doesn't contain anything but the rule numbers, the misra.py script runs correctly (finds the violations correct) but when it can't process the MISRA.txt it doesn't throw an error it glitches out and doesn't work properly.

      Hmm, what I can reproduce is this:
      If I remove the rule text from a rule in the rule texts file then corresponding errors are not shown any longer.
      IIRC this is more a feature than a bug.
      By only adding necessary rules to a rule texts file the rules that are not present are suppressed.

      I am not sure if it makes sense to suppress rules which are present with their number but without a text. It could make sense to suppress rules this way but it could also make sense to warn that a text is missing.

       
  • Daniel Marjamäki

    interesting. so I guess we need some better logging when it "glitches out" then.

     
  • versat

    versat - 2020-01-23

    Just an idea: We could add a button in the GUI for testing the MISRA configuration/requirements like Python installation/binary and rule text file.

    @Richard Bamford: Can you check if the "Analysis Log" in the GUI gives any information about a problem with the MISRA analysis? I have added some output for cases where there is a problem with Python. I guess that for your case there is nothing logged, but who knows.

     
    👍
    1
    • Richard Bamford

      Richard Bamford - 2020-01-23

      I will do, which version should i use?

       
      • versat

        versat - 2020-01-24

        1.90 should be fine.

         
        • Richard Bamford

          Richard Bamford - 2020-01-25

          There are no errors specifically for python but these errors do appear when i check "show internal errors in log":

          https://pastebin.com/t3v5s55v

           
          • versat

            versat - 2020-01-27

            Thanks. Indeed, there are no hints for any real issues. These bailout warnings are normally no real errors. Seems like the issue actually is either not detected or at least not logged.
            That needs fixing.

             

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.