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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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 ?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
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.
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 ?
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".
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
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 :-)
I had nothing to complain about. Clean and simple. It has been merged. Congratulations, you are now a Cppcheck contributor. :-)