Re: PCI Express support for 2.4 kernel

Vladimir Kondratiev
2003-12-15T15:52:45Z

OK, I almost convinced it may be removed.
My point is, this initialization with 0 cost nothing. Readability and
clearness of code do matter, on my opinion. I think when one states
explicitly he expect variable to have 0 value, it is better then use
implicit rules.

To illustrate zero cost, I did the following test:
[tmp]$ cat t.c; gcc -S t.c; cat t.s
static int a1=0;
static int a2;
/* EOF */

.file "t.c"
.local a1
.comm a1,4,4
.local a2
.comm a2,4,4
.section .note.GNU-stack,"",@progbits
.ident "GCC: (GNU) 3.3.1 20030811 (Red Hat Linux 3.3.1-1)"

As you can see, assembly code is identical, compiler did this trivial
optimization for me.

Vladimir.

Mark Hahn wrote:

>>>>+static void* rrbar_virt=NULL;
>>>>
>>>>
>>>Do not bother initializing static variables to zero. This just wastes
>>>bss space, since these variables are automatically zeroed for you,
>>>anyway.
>>>
>>>
>>I did not found this feature in standard. More, future versions of gcc
>>will give at least warning, if not error, like "use of uninitialized
>>variable". Many good sources also say it is good practice to initialize
>>all variables. I rely on its value later. I' ll keep it as is unless
>>really strong arguments provided.
>>
>>
>
>it'll get your code rejected. static variables are always, everywhere,
>initialized to zero (OK, probably not embedded environments). this is
>a code standard, not a matter of taste.
>
>
>