Error in published patch to smbd/filename.c

Andrew Tridgell tridge at linuxcare.com
Mon Nov 27 12:32:00 GMT 2000


> Actually, I don't think it matters as anything defined as
> static and not initialized is automatically put into the BSS
> segment, which is implicitly zero.
> 
> Your patch does make the intent clearer though, thanks.

nope, the patch is wrong.

The reason you should NOT initialise static variables that you want to
start as zero is that it makes the binaries larger and slower to
load. Try running "size" on binaries with and without initialisation
and compare the size of the resulting binaries. Think about where the
initial values of the variables come from in the two cases. We should
put variables in the bss whenever possible to try to lower the
resources required by Samba.

btw, I have often heard misguided individuals say that you can't rely
on static variables starting as zero. That is rubbish. The behaviour
is defined by the C standard and is OK to rely on. I have seen one
system where it was broken (a weird parallel OS called CellOS that I
worked on a while back) but the correct fix was to the badly broken OS
kernel, not to the programs running on it.




More information about the samba-technical mailing list