Re: checkpatch.pl and statics

From: Benny Halevy
Date: Sun Mar 16 2008 - 09:35:58 EST


On Mar. 13, 2008, 17:43 +0200, Bernd Petrovitsch <bernd@xxxxxxxxx> wrote:
> On Don, 2008-03-13 at 16:09 +0100, Andreas Westin XX wrote:
> [....]
>> I ran checkpatch.pl on a piece of code I wrote and besides all the other
>> warnings/errors it complained about a static pointer being initialised
>> to NULL/0. I fixed it but I'm curious as to why this is not permitted ?
>
> Because "uninitialized" data is automatically initialized wit 0. An
> explicit initialization with 0/NULL wastes space in the kernel image.

gcc (at least version >= 4.1.2) seems to smarter than that. It
doesn't seem to put data initialized to zero in the initialized data
segment but rather adds it to the uninitialized data. That said,
initializing statically allocated data to zero is superfluous in C
and should be avoided for style/elegance reasons as well.

Benny

>
> Bernd

--
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/