Re: my handy-dandy, "coding style" script

From: David Rientjes
Date: Tue Dec 19 2006 - 16:24:52 EST


On Tue, 19 Dec 2006, Jan Engelhardt wrote:

> > I don't know if anyone cares about them anymore, since I think gcc
> > grew some smarts in the area recently, but there are a lot of lines of
> > code matching "static int.*= *0;" and equivalents in the driver tree.
>
> I'd really like to see the C compiler being enhanced to detect
> "stupid casts", i.e. those, which when removed, do not change (a) the outcome
> (b) the compiler warnings/error output.
>

If your desire is for the compiler warnings output to be unchanged, I'm
not sure how you'd enhance the compiler from detecting these casts. All
of the casts that have been removed in these cleanup patches do not change
the assembly when using gcc; they simply reduce the amount of visual noise
in the source code.

This is also true in terms of global static variables being initialized to
0 (or NULL). While it is indeed unnecessary by the standard, it simply
moves the initialization from one segment of the assembly to the other,
regardless of how many different functions it is referenced in. gcc does
not emit movl $0, var for these cases.

It _would_ be helpful to add a macro such as:

#define SILENCE_GCC(x) = x

to eliminate warnings such that:

auto int a SILENCE_GCC(a);
fill_a(&a);
if (a)
...

would not produce a "may be used uninitialized" warning.

David
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/