I have 2 queries in resource leak detection by Cpp check.
1 Query:
I have downloaded cpp check source code from this link https://launchpad.net/ubuntu/+source/cppcheck/2.2-1 and kept for build in 18.04 and 16.04 ubuntu Host PCs. I have a c file in which a function check_conf() is smthng like below
Here the fclose pointed is causing the confusion. If I comment the while loop and fclose() then resource leak detection happens in ubuntu 18.04. If I dont comment the while loop and comment only the fclose(), no resorce leak detection happens in 18.04. This case I have not checked in 16.04. Since 18.04 is my target host PC.
Need help to understand this .
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have a file xyz.c and it has a lot of include files which is given
as an so file from third party. Whether is it possible to use so
libraries during the static analysis of xyz.c file?
How can I run cppcheck on multiple files at a time?
Regards,
Anjali
On 30/11/20 11:03 pm, "Daniel Marjamäki" wrote:
That is strange I cannot explain it.
you must declare fp otherwise Cppcheck will not detect issues.
cppcheck cannot analyze so files. you are supposed to use --library to handle external dependencies.
use cppcheck folder to check all files in folder (recursively).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I have 2 queries in resource leak detection by Cpp check.
1 Query:
I have downloaded cpp check source code from this link https://launchpad.net/ubuntu/+source/cppcheck/2.2-1 and kept for build in 18.04 and 16.04 ubuntu Host PCs. I have a c file in which a function check_conf() is smthng like below
I missed the fclose() during implementation time. And during static analysis in ubuntu 18.04 with below command
./cppcheck --dump config_api.c --enable=warning,performance,portability --std=c11
Resource leak is not detected .But in 16.04 it is detected.
Why it is so when both host PCSs are having cppcheck executable from same base code?
2 Query:
Here the fclose pointed is causing the confusion. If I comment the while loop and fclose() then resource leak detection happens in ubuntu 18.04. If I dont comment the while loop and comment only the fclose(), no resorce leak detection happens in 18.04. This case I have not checked in 16.04. Since 18.04 is my target host PC.
Need help to understand this .
Last edit: Daniel Marjamäki 2020-11-30
Hi Daniel,
Thank You for the reply.
I have couple of questions too.
I have a file xyz.c and it has a lot of include files which is given
as an so file from third party. Whether is it possible to use so
libraries during the static analysis of xyz.c file?
How can I run cppcheck on multiple files at a time?
Regards,
Anjali
On 30/11/20 11:03 pm, "Daniel Marjamäki" wrote:
cppcheck cannot analyze so files. you are supposed to use --library to handle external dependencies.
use
cppcheck folder
to check all files in folder (recursively).For details how to use cppcheck please see the manual: http://cppcheck.sourceforge.net/manual.pdf
If you have some feedback on the manual feel free to share it.