Re: [RFC][PATCH 0/9] -Wshadow: Making the kernel build clean with -Wshadow

From: Valdis . Kletnieks
Date: Mon Jul 10 2006 - 09:48:42 EST


On Mon, 10 Jul 2006 14:53:19 +0200, Arjan van de Ven said:

> I'm just about always in favor of having automated tools help us find
> bugs. However... can you give an indication of how many real bugs you
> have encountered? If it's "mostly noise" all the time.. then it's maybe
> not worth the effort... while if you find real bugs then it's obviously
> worthwhile to go through this.

I started doing similar a while back, and I hadn't come across any
actual bugs either. However, there's 2 aspects to this:

1) The cleanup cases that Jesper is doing (which are pretty similar
to what I was doing) are mostly "function prototypes in .h files use
a variable name that collides with another global variable" ('up' for
example). (My nominee for patch 10/9:

include/net/tcp.h:469: warning: declaration of '__x' shadows a previous local
include/net/tcp.h:469: warning: shadowed declaration is here

2) The actual *bugs* are most probably in the "variable in .c file
shadows a global".

As Jesper notes, it's hard to see the latter when there's 38,000+ noise
warnings....

To get a good estimate of the *actual* bug rate, grep for how many *.c files
trigger the warning when built with -Wshadow - there's 695 of *those* in
my current config.

When I did a bunch of cleanups a while ago to make -Wundef work, I think
I scared up exactly one actual bug - but it was a subtle one in the NFS
code that wouldn't have been easu to find otherwise...

Attachment: pgp00000.pgp
Description: PGP signature