MISRA addon works fine if it can locate the header file, gives the follow error message if it cant locate Atype.h file:
Id: internalError
Bailing out from checking C:\Working\Dev2\main.c since there was an internal error: Failed to execute addon (command: 'C:\Users\XX\AppData\Local\Programs\Python\Python38-32\python.exe "C:\Program Files\Cppcheck\addons\misra.py" --cli --rule-texts=C:/Working/misra_rules_multiple_lines.txt C:\Working\Dev2\ff-cppcheck-build-dir\main.a1.dump')
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Could you please run this command from the command line: C:\Users\XX\AppData\Local\Programs\Python\Python38-32\python.exe "C:\Program Files\Cppcheck\addons\misra.py" --cli --rule-texts=C:/Working/misra_rules_multiple_lines.txt C:\Working\Dev2\ff-cppcheck-build-dir\main.a1.dump and send its output?
I think the problem is in incorrect slashes in the MISRA rules path: C:/Working/misra_rules_multiple_lines.txt should be C:\Working\misra_rules_multiple_lines.txt.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The output on the command line when I ran the command you sent is:
Traceback (most recent call last):
File "C:\Program Files\Cppcheck\addons\misra.py", line 3620, in <module>
main()
File "C:\Program Files\Cppcheck\addons\misra.py", line 3564, in main
checker.parseDump(item)
File "C:\Program Files\Cppcheck\addons\misra.py", line 3396, in parseDump
self.executeCheck(902, self.misra_9_2, cfg)
File "C:\Program Files\Cppcheck\addons\misra.py", line 3343, in executeCheck
check_function(*args)
File "C:\Program Files\Cppcheck\addons\misra.py", line 1745, in misra_9_2
checkArrayInitializer(eq.astOperand2, dimensions, valueType)
File "C:\Program Files\Cppcheck\addons\misra.py", line 1573, in checkArrayInitializer
elements = getRecordElements(valueType) if valueType.type == 'record' else None
AttributeError: 'NoneType' object has no attribute 'type'</module>
This was run when main.c could not include Atype.h; this is the condition that produces the intermalError. I repeated the command with C:\Working\misra_rules_multiple_lines.txt as the windows MISRA rules path and the output was identical (as above)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It seems that the error lies in the MISRA 9.2 rule, which was recently rewritten. At least, I can't reproduce this problem with the given source code using Cppcheck from the main branch.
I see two possible workarounds here:
1. Build and install the latest Cppcheck from the sources. This will solve the problem with misra.py crashes.
2. Or you can temporary suppress MISRA 9.2 rule as it described in the manual. Then, you can update to Cppcheck 2.4 when it releases and remove the suppression.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Using Cppcheck 2.3 GUI
Created simple example to show the issue, that might need fixing
MISRA addon works fine if it can locate the header file, gives the follow error message if it cant locate Atype.h file:
Id: internalError
Bailing out from checking C:\Working\Dev2\main.c since there was an internal error: Failed to execute addon (command: 'C:\Users\XX\AppData\Local\Programs\Python\Python38-32\python.exe "C:\Program Files\Cppcheck\addons\misra.py" --cli --rule-texts=C:/Working/misra_rules_multiple_lines.txt C:\Working\Dev2\ff-cppcheck-build-dir\main.a1.dump')
Hello, Daniel,
Could you please run this command from the command line: C:\Users\XX\AppData\Local\Programs\Python\Python38-32\python.exe "C:\Program Files\Cppcheck\addons\misra.py" --cli --rule-texts=C:/Working/misra_rules_multiple_lines.txt C:\Working\Dev2\ff-cppcheck-build-dir\main.a1.dump and send its output?
I think the problem is in incorrect slashes in the MISRA rules path: C:/Working/misra_rules_multiple_lines.txt should be C:\Working\misra_rules_multiple_lines.txt.
Hello Georgiy,
The output on the command line when I ran the command you sent is:
Traceback (most recent call last):
File "C:\Program Files\Cppcheck\addons\misra.py", line 3620, in <module>
main()
File "C:\Program Files\Cppcheck\addons\misra.py", line 3564, in main
checker.parseDump(item)
File "C:\Program Files\Cppcheck\addons\misra.py", line 3396, in parseDump
self.executeCheck(902, self.misra_9_2, cfg)
File "C:\Program Files\Cppcheck\addons\misra.py", line 3343, in executeCheck
check_function(*args)
File "C:\Program Files\Cppcheck\addons\misra.py", line 1745, in misra_9_2
checkArrayInitializer(eq.astOperand2, dimensions, valueType)
File "C:\Program Files\Cppcheck\addons\misra.py", line 1573, in checkArrayInitializer
elements = getRecordElements(valueType) if valueType.type == 'record' else None
AttributeError: 'NoneType' object has no attribute 'type'</module>
This was run when main.c could not include Atype.h; this is the condition that produces the intermalError. I repeated the command with C:\Working\misra_rules_multiple_lines.txt as the windows MISRA rules path and the output was identical (as above)
It seems that the error lies in the MISRA 9.2 rule, which was recently rewritten. At least, I can't reproduce this problem with the given source code using Cppcheck from the main branch.
I see two possible workarounds here:
1. Build and install the latest Cppcheck from the sources. This will solve the problem with misra.py crashes.
2. Or you can temporary suppress MISRA 9.2 rule as it described in the manual. Then, you can update to Cppcheck 2.4 when it releases and remove the suppression.
Thanks for your help and looking into this issue. I will go with the option to suppress the rule for now