Menu

MISRA addon rule 4.1 doesn't find all non-compliant code examples

2019-05-21
2019-05-22
  • Mathias Schmid

    Mathias Schmid - 2019-05-21

    The MISRA addon doesn't find the non-compliant example for octal value of Rule 4.1 defined by MISRA C 2012 document . In function "misra_4_1" of misra.py token is skipped if it doesn't start with double quotes. From my point of view it should check for single quote too. I modified the initial check of Rule 4.1 to << if ((token.str[0] != '"') and (token.str[0] != '\'')): >> which seems to work . I use the latest release cppcheck 1.87 on Windows 10.

     
  • Daniel Marjamäki

    Thanks! I wonder if you could create a pull request on github? I prefer a github pull request but if you provide a patch that is ok also.

    A proper test case must be added in addons/test/misra-test.c also.

     
  • Mathias Schmid

    Mathias Schmid - 2019-05-21

    I just created an account at GitHub and try to provide a pull request. Need some time to get familiar with this platform and the rules. Should the test case just contain non-compliant examples or passing compliant examples too ?

     
  • Daniel Marjamäki

    ok. it's pretty straight forward I think. Procedure:
    1. Go to https://github.com/danmar/cppcheck with your browser and click on the "Fork" button..
    2. clone your cppcheck repo : git clone https://github.com/your_username/cppcheck.git
    3. Create a branch for this : cd cppcheck; git checkout -b misra
    4. modify the files
    5. Commit your changes locally : git commit -a
    6. Push your changes to your github cppcheck repo : git push -u origin misra
    -- The "-u origin misra" should only be needed the first time. After that you can just use "git push"
    7. When you are done. Go to https://github.com/danmar/cppcheck in your browser and click on "New pull request".

    Should the test case just contain non-compliant examples or passing compliant examples too ?

    There are existing tests for this rule already. So extend those properly. If you only add 1 small test that will ensure your specific fix is working that is good enough for me.

     

    Last edit: Daniel Marjamäki 2019-05-22
  • Mathias Schmid

    Mathias Schmid - 2019-05-22

    Ok, pull request has been added. Thanks for your help on getting this done.
    I hope my first pull request will not end up in a shitstorm :-)

     
  • Daniel Marjamäki

    I had nothing to complain about. Clean and simple. It has been merged. Congratulations, you are now a Cppcheck contributor. :-)

     

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.