$ cat leak-fp.c #include <stdio.h> void leak_fp_fopen(char *fn) { fopen(fn, "r"); } void leak_fp_fdopen(FILE *fp) { fdopen(fileno(fp), "r"); } $ cppcheck leak-fp.c /Users/jhi/leak-fp.c:4:5: error: Return value of allocation function 'fopen' is not stored. [leakReturnValNotUsed] fopen(fn, "r"); ^ $ cppcheck --version Cppcheck 2.5
Did you use " --library=posix", at commandline? It should provide information of fdopen to Cppcheck.
orbitcowboy wrote:
Ah, no I did not. I wasn't aware of this option. With that, cppcheck does correctly flag that use of fdopen. Thanks!
Now I need to figure out how to pass that flag to cppcheck when I am using the Emacs flycheck-mode (that's how I usually interface with cppcheck).
fopen leak detected, fdopen leak not detected (cppcheck 2.5.1) https://sourceforge.net/p/cppcheck/discussion/development/thread/e459fa478c/?limit=25#fe1f Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/cppcheck/discussion/development/ To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/
fopen leak detected, fdopen leak not detected (cppcheck 2.5.1) https://sourceforge.net/p/cppcheck/discussion/development/thread/e459fa478c/?limit=25#fe1f
Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/cppcheck/discussion/development/
To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/
Log in to post a comment.
Did you use " --library=posix", at commandline? It should provide information of fdopen to Cppcheck.
orbitcowboy wrote:
Ah, no I did not. I wasn't aware of this option. With that, cppcheck
does correctly flag that use of fdopen. Thanks!
Now I need to figure out how to pass that flag to cppcheck when I am
using the Emacs flycheck-mode (that's how I usually interface with
cppcheck).