I use a Python script for some checks based on Cppcheck dump-files. The following functions are functional equal. The second function contains some unnecessary lines of code but in the dump-file the lambda function is missing. Used version: Cppcheck 2.3 (Windows 10). First function and dump-file extract: bool hasMember() { return (std::any_of(memberList.cbegin(), memberList.cend(), [](MemberTag tag) { return (tag != MemberTag::NoMember); } )); } <scope id="000001D110D55810" type="Function" className="hasMember"...
I use a Python script for some checks based on Cppcheck dump-files. The following functions are functional equal. The second function contains some unnecessary lines of code but in the dump-file the lambda function is missing. First function and dump-file extract: bool hasMember() { return (std::any_of(memberList.cbegin(), memberList.cend(), [](MemberTag tag) { return (tag != MemberTag::NoMember); } )); } <scope id="000001D110D55810" type="Function" className="hasMember" bodyStart="000001D110E00710"...
ENV33-C defines an exception to call system() using a null pointer to check presence of command processor. The current implementation in cert.py does a strict check and reports system(NULL) and system(0) as violation. CERT-C states that exceptions are informative only and are not required to be followed. Is it intended to check rules this strict way and ignore exceptions ? If exceptions should be treated as compliant this might be done by adding two simpleMatch checks def env33(data): for token in...
I mean int c41_6 = '\0\t'; int c41_7 = '\12\t'; MISRA rule 4.1 states int c41_4 = '\141\t'; as compliant and the above lines just use less than 3 octal digits. The checker state them as non-compliant. It's the same as for the initial comment: int c41_5 = '\0'; uses just less octal digits but should not generate a MISRA 4.1 violation. Hope this sounds plausible ?
The checker for MISRA rule 4.1 works fine for compliant and non-compliant examples part of MISRA 2012 document. However if the hexadecimal and octal escape sequences are not of full length (\x + 2 hex digits or \ + 3 octal digits) than the checker generates false positives. The following lines generate false positives but from my point of view they are compliant. The last one leads to an out of range exception and terminates the MISRA python addon. const char *s41_3 = "\x41\xA"; const char *s41_4...
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 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 ?
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.