linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* cppcheck and btrfs
@ 2011-03-14 20:32 Chris Samuel
  2011-03-14 22:24 ` Ilya Dryomov
  0 siblings, 1 reply; 2+ messages in thread
From: Chris Samuel @ 2011-03-14 20:32 UTC (permalink / raw)
  To: linux-btrfs, Chris Mason

[-- Attachment #1: Type: text/plain, Size: 1354 bytes --]

Hi Chris, et. al,

I've recently come across cppcheck (static analyser for C code)
and ran it on the current btrfs directory from Linus's repo and
it's reported the following potential issues:

linux-2.6$ cppcheck -q fs/btrfs/
[fs/btrfs/compression.c:343]: (error) Data is allocated but not initialized: 
cb
[fs/btrfs/compression.c:583]: (error) Data is allocated but not initialized: 
cb
[fs/btrfs/delayed-ref.c:649]: (error) Data is allocated but not initialized: 
ref
[fs/btrfs/delayed-ref.c:694]: (error) Data is allocated but not initialized: 
ref
[fs/btrfs/extent-tree.c:5766]: (error) Data is allocated but not initialized: 
extent_op
[fs/btrfs/extent-tree.c:5768]: (error) Data is allocated but not initialized: 
extent_op
[fs/btrfs/transaction.c:1161]: (error) Data is allocated but not initialized: 
ac
[fs/btrfs/volumes.c:1387]: (error) Possible null pointer dereference: 
fs_devices
[fs/btrfs/volumes.c:3636]: (error) Memory leak: device

Now I'm not really a programmer (much less a kernel one) but I
do see people using it discover issues in kernel code.

Are these issues real or bugs in cppcheck ?

cheers!
Chris
-- 
 Chris Samuel  :  http://www.csamuel.org/  :  Melbourne, VIC

This email may come with a PGP signature as a file. Do not panic.
For more info see: http://en.wikipedia.org/wiki/OpenPGP

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 482 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: cppcheck and btrfs
  2011-03-14 20:32 cppcheck and btrfs Chris Samuel
@ 2011-03-14 22:24 ` Ilya Dryomov
  0 siblings, 0 replies; 2+ messages in thread
From: Ilya Dryomov @ 2011-03-14 22:24 UTC (permalink / raw)
  To: Chris Samuel; +Cc: linux-btrfs, Chris Mason

On Tue, Mar 15, 2011 at 07:32:13AM +1100, Chris Samuel wrote:
> Hi Chris, et. al,
> 
> I've recently come across cppcheck (static analyser for C code)
> and ran it on the current btrfs directory from Linus's repo and
> it's reported the following potential issues:
> 
> linux-2.6$ cppcheck -q fs/btrfs/
> [fs/btrfs/compression.c:343]: (error) Data is allocated but not initialized: 
> cb
> [fs/btrfs/compression.c:583]: (error) Data is allocated but not initialized: 
> cb
> [fs/btrfs/delayed-ref.c:649]: (error) Data is allocated but not initialized: 
> ref
> [fs/btrfs/delayed-ref.c:694]: (error) Data is allocated but not initialized: 
> ref
> [fs/btrfs/extent-tree.c:5766]: (error) Data is allocated but not initialized: 
> extent_op
> [fs/btrfs/extent-tree.c:5768]: (error) Data is allocated but not initialized: 
> extent_op
> [fs/btrfs/transaction.c:1161]: (error) Data is allocated but not initialized: 
> ac

All of these seems to be warnings cautioning about passing a pointer to
an uninitialized area of memory to some function.  But in most cases
it's an accepted convention, where the called function unconditionally
initializes that memory area, before using it, so it's OK.

> [fs/btrfs/volumes.c:1387]: (error) Possible null pointer dereference: 
> fs_devices

This one is very unlikely, however I doubt a lot of people tested Btrfs
seeding functionality, so it's probably the only one worth looking at.

> [fs/btrfs/volumes.c:3636]: (error) Memory leak: device

This one is bogus, device struct is linked via fs_devices->devices list.

> Now I'm not really a programmer (much less a kernel one) but I
> do see people using it discover issues in kernel code.
> 
> Are these issues real or bugs in cppcheck ?
> 
> cheers!
> Chris
> -- 
>  Chris Samuel  :  http://www.csamuel.org/  :  Melbourne, VIC
> 
> This email may come with a PGP signature as a file. Do not panic.
> For more info see: http://en.wikipedia.org/wiki/OpenPGP

Thanks,

		Ilya

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-03-14 22:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-14 20:32 cppcheck and btrfs Chris Samuel
2011-03-14 22:24 ` Ilya Dryomov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).