* latest fio source code check using cppcheck
@ 2012-02-09 15:19 Roger Sibert
2012-02-09 19:55 ` Jens Axboe
0 siblings, 1 reply; 2+ messages in thread
From: Roger Sibert @ 2012-02-09 15:19 UTC (permalink / raw)
To: fio
I was going through my own source code attempting to clean up the code
and spotted the new drop of fio. On occasion I write something in C
which gets passed along so I do try to maintain proper coding, I
recently took to checking my code with cppcheck to make sure it would
atleast pass static coding checks.
cppcheck is opensource and available at sourceforge, I am using the
latest version not the one that comes in most linux distros.
CAVEAT EMPTOR - static code checks can generate some false hits
From the root directory of the latest git of the source
cppcheck --enable=all -f .
or if you want more detail in the error reports
cppcheck --enable=all -f -v .
That will force a check of all ifdefs (yes fio has a bunch) and return
all possible errors and style based issues.
To keep it brief a quick cut and paste instead of the entire return.
Checking crc/crc32c-intel.c: __ia64__...
[arch/arch-ia64.h:34]: (style) Statements following return, break,
continue, goto or throw will never be executed
Checking mutex.c: MADV_FREE;__FreeBSD__...
[mutex.c:26]: (style) Variable 'mflag' is assigned a value that is never
used
Checking mutex.c: MADV_FREE;__sun__...
[os/os-solaris.h:114]: (style) The scope of the variable 'ret' can be
reduced
[os/os-solaris.h:126]: (style) The scope of the variable 'ret' can be
reduced
[os/os-solaris.h:114]: (style) Variable 'ret' is assigned a value that
is never used
[os/os-solaris.h:126]: (style) Variable 'ret' is assigned a value that
is never used
Checking mutex.c: __CYGWIN__...
[os/os-windows.h:151]: (style) The scope of the variable 'winpid' can be
reduced
[os/os-windows.h:125]: (error) Common realloc mistake: 'ids' nulled but
not freed upon failure
[lib/getopt_long.c:41]: (style) The function 'getopt_long_only' is never
used
[lib/num2str.c:8]: (style) The function 'num2str' is never used
Checking parse.c...
[parse.c:183]: (error) Memory leak: c
[parse.c:224]: (warning) scanf without field width limits can crash with
huge input data
[parse.c:324]: (warning) scanf without field width limits can crash with
huge input data
[parse.c:327]: (warning) scanf without field width limits can crash with
huge input data
[lib/getopt_long.c:41]: (style) The function 'getopt_long_only' is never
used
[lib/num2str.c:8]: (style) The function 'num2str' is never used
(information) Cppcheck cannot find all the include files (use
--check-config for details)
The result of the --check-config
Checking t/ieee754.c...
[t/ieee754.c:2]: (information) Include file: "../ieee754.h" not found
For completeness.
Linux virtually-putzu 2.6.32-31-generic #61-Ubuntu SMP Fri Apr 8
18:25:51 UTC 2011 x86_64 GNU/Linux
Thanks,
Roger
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: latest fio source code check using cppcheck
2012-02-09 15:19 latest fio source code check using cppcheck Roger Sibert
@ 2012-02-09 19:55 ` Jens Axboe
0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2012-02-09 19:55 UTC (permalink / raw)
To: Roger Sibert; +Cc: fio
On 2012-02-09 16:19, Roger Sibert wrote:
> I was going through my own source code attempting to clean up the code
> and spotted the new drop of fio. On occasion I write something in C
> which gets passed along so I do try to maintain proper coding, I
> recently took to checking my code with cppcheck to make sure it would
> atleast pass static coding checks.
>
> cppcheck is opensource and available at sourceforge, I am using the
> latest version not the one that comes in most linux distros.
>
> CAVEAT EMPTOR - static code checks can generate some false hits
>
> From the root directory of the latest git of the source
>
> cppcheck --enable=all -f .
> or if you want more detail in the error reports
> cppcheck --enable=all -f -v .
>
> That will force a check of all ifdefs (yes fio has a bunch) and return
> all possible errors and style based issues.
>
> To keep it brief a quick cut and paste instead of the entire return.
Thanks, a few useful ones in there. I've applied a joint fix for them.
> Checking crc/crc32c-intel.c: __ia64__...
> [arch/arch-ia64.h:34]: (style) Statements following return, break,
> continue, goto or throw will never be executed
Not sure what this is trying to say.
> Checking mutex.c: MADV_FREE;__FreeBSD__...
> [mutex.c:26]: (style) Variable 'mflag' is assigned a value that is never
> used
Not a bug, but can be cleaned up. Done.
> Checking mutex.c: MADV_FREE;__sun__...
> [os/os-solaris.h:114]: (style) The scope of the variable 'ret' can be
> reduced
> [os/os-solaris.h:126]: (style) The scope of the variable 'ret' can be
> reduced
> [os/os-solaris.h:114]: (style) Variable 'ret' is assigned a value that
> is never used
> [os/os-solaris.h:126]: (style) Variable 'ret' is assigned a value that
> is never used
Killed 'ret', not needed.
> Checking mutex.c: __CYGWIN__...
> [os/os-windows.h:151]: (style) The scope of the variable 'winpid' can be
> reduced
Pointless.
> [os/os-windows.h:125]: (error) Common realloc mistake: 'ids' nulled but
> not freed upon failure
Don't immediately see anything wrong here.
> [lib/getopt_long.c:41]: (style) The function 'getopt_long_only' is never
> used
> [lib/num2str.c:8]: (style) The function 'num2str' is never used
Both are used.
> Checking parse.c...
> [parse.c:183]: (error) Memory leak: c
Bug fixed.
> [parse.c:224]: (warning) scanf without field width limits can crash with
> huge input data
> [parse.c:324]: (warning) scanf without field width limits can crash with
> huge input data
> [parse.c:327]: (warning) scanf without field width limits can crash with
> huge input data
Single value, not bothering with these.
> [lib/getopt_long.c:41]: (style) The function 'getopt_long_only' is never
> used
> [lib/num2str.c:8]: (style) The function 'num2str' is never used
Duplicate, they are used.
--
Jens Axboe
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-02-09 19:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-09 15:19 latest fio source code check using cppcheck Roger Sibert
2012-02-09 19:55 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox