Re: latest fio source code check using cppcheck

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
To unsubscribe from this list: send the line "unsubscribe fio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel]     [Linux SCSI]     [Linux IDE]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux