Hi all,
I am having troubles with Misra rules 17.7 checks.
The Misra add-on detects that memset returns code is not tested and generates an error => Good.
But it doesn't detects that memcpy retunr code isn't tested => Not good.
"c:\Cppcheck\cppcheck.exe"-DMDF4_TEST_ABG5--enable=all--inline-suppr--suppress=unusedFunction--suppress=missingInclude--addon=./misra.json ./*.cChecking essai_misra_17_7.c ...Checking essai_misra_17_7.c: MDF4_TEST_ABG5=1...essai_misra_17_7.c:5:11: style: The value returned by a function having non-void return type shall be used [misra-c2012-17.7] memset( acBufferTemp , 0 , sizeof(acBufferTemp) ); /* Reset buffer */
memset and memcpy return void pointer. They both should generate deviation to Misra 17.7 rule.
*
I have checked in dump file and type pointer field is equal to 1. So the python script should generates an error, but doesn't. I don't know why.
thanks georgy! Sounds like an easy fix. update memcpy configuration in cfg/std.cfg file. If this line is added: <returnValue type="void*"/> then the return type should be added.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
nofile:0:0: information: Failed to load std.cfg. Your Cppcheck installation is broken, please re-install. The Cppcheck binary was compiled without FILESDIR set. Either the std.cfg should be available in c:/Cppcheck/cfg or the FILESDIR should be configured. [failedToLoadCfg]
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Daniel, i have installed CppCheck V2.1 and unzip it in C:\CppCheck. That's all.
Then i call CppCheck directly in pre-build (for naming convention) and post-build rules (for misra rules). I have just downloaded the std.cfg file from https://github.com/danmar/cppcheck/commit/98b62384504f539d06c686fdc5dbaf0cdf14daa7 and copy it in C:\CppCheck/cfg directory. And it gives me this error. I don't know why. I have replaced it with my old std.cfg files and it runs well.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi all,
I am having troubles with Misra rules 17.7 checks.
The Misra add-on detects that memset returns code is not tested and generates an error => Good.
But it doesn't detects that memcpy retunr code isn't tested => Not good.
The code:
My line of command with result below:
memset and memcpy return void pointer.
They both should generate deviation to Misra 17.7 rule.
*
I have checked in dump file and type pointer field is equal to 1. So the python script should generates an error, but doesn't. I don't know why.
Hello,
Thanks for the report.
It seems that problem not in MISRA addon. For some reasons, Cppcheck does not include value type of memcpy function in the dump file.
Here is a minimal example:
This code produces the following tokens in the dump file:
The
(
token after memcpy does not contain the value type, expected by misra.py here: https://github.com/danmar/cppcheck/blob/1daf1ec108f66633f49c51a778988fe337d6cf13/addons/misra.py#L2162thanks georgy! Sounds like an easy fix. update memcpy configuration in cfg/std.cfg file. If this line is added:
<returnValue type="void*"/>
then the return type should be added.Thanks, here is a fix: https://github.com/danmar/cppcheck/pull/2777
This patch fixes MISRA 17.7 false positives.
Thank you very much for your good job!
I have implemented the fix and it works well... 58 new MISRA errors in my code !
Note: It was false negatives.
Hi all,
i have checked the std.cfg file and it seems that the problem occurs also for the following functions (which have no return type dexcribed):
Is it possible to add the return type for these two functions please ?
Last edit: Jean-Loic MARTIN 2020-09-14
do you think you could create a github pull request to fix such problems?
I never used github. I have created an account but don't know how to do a accurate pull request.
Return value types added with https://github.com/danmar/cppcheck/commit/98b62384504f539d06c686fdc5dbaf0cdf14daa7
Could you give it a try?
Hi , with your file, it gives me an error :
nofile:0:0: information: Failed to load std.cfg. Your Cppcheck installation is broken, please re-install. The Cppcheck binary was compiled without FILESDIR set. Either the std.cfg should be available in c:/Cppcheck/cfg or the FILESDIR should be configured. [failedToLoadCfg]
that is a major problem. how do you compile/install? do you run the CLI or GUI?
Hi Daniel, i have installed CppCheck V2.1 and unzip it in C:\CppCheck. That's all.
Then i call CppCheck directly in pre-build (for naming convention) and post-build rules (for misra rules). I have just downloaded the std.cfg file from https://github.com/danmar/cppcheck/commit/98b62384504f539d06c686fdc5dbaf0cdf14daa7 and copy it in C:\CppCheck/cfg directory. And it gives me this error. I don't know why. I have replaced it with my old std.cfg files and it runs well.