[dm-devel] Re: [KJ] [PATCH] dm: uninitialize static variables

Jaco Kroon jaco at kroon.co.za
Mon Dec 12 07:17:33 UTC 2005


In reply to Nicolas Kaiser
> * "Carlos Manuel Duclos Vergara" <carlos at embedded.cl>:
>> > uninitialize static variables initialized to 0, to make them go
>> > to .bss instead of .data.
>> >
>>
>> if you want that why not explicitely put them in .bss?
>> something like:
>>
>> > -static unsigned int major = 0;
>> > +static unsigned int major; /* = 0 */
>>
>> static unsigned int major = 0 __attribute__ ((section(".bss"));
>
> I personally like the idea of explicitly expressing this intention,
> but I didn't manage to achieve this together with initialization.
> I tried

>From http://janitor.kernelnewbies.org/TODO:

- uninitialize static variables initialized to 0, to make it go to the .bss,
  instead of .data.
  __initdata inside functions has to be initialized, even if to 0 though.

Therefor I would go with

static unsigned int major; /* = 0 */

Let the compiler make the decision, it will make the correct one.  The
comment is just there to indicate that we haven't forgotten to initialise
it.  As soon as you explicitly initialise you force the compiler to place
it somewhere other than bss.


-- 
There are 10 kinds of people in the world, those who understand binary,
and those who don't.




More information about the dm-devel mailing list