Re: [PATCH] mutliple root devs (take II)

From: Tigran Aivazian (tigran@veritas.com)
Date: Fri Dec 01 2000 - 12:16:58 EST


On Fri, 1 Dec 2000, T. Camp wrote:
> Hmm didn't know that, from the user-land portable C perspective I'm in the
> habit of zero'ing everything. - thanks.

Yes, sorry, I should have explained a bit more, perhaps. The point is that
when you have an unitialized variable like this:

int x;

the C compiler does not reserve any space for it in the final object file
but rather puts special information in a section called BSS which tells
how much stuff is there, so an appropriate memory image is created for
that section during loading. Subsequently, the kernel initialisation code
(see arch/i386/kernel/head.S, grep for BSS) explicitly initializes the
content of that segment to 0 to comply with various ANSI C standards that
demand this (which presumably demand this for the very reason of making
such optimization possible).

So, not initializing things explicitly saves space in the final disk image
and is a common technique used (by far!) by the majority of Linux kernel
code. In the past, I remember, some arguments against it such as 'having
explicit 0 initialization better documents the code' but, of course, they
are not valid because that is what we have /* */ for -- for documentation.
Comments should not waste space or time.

Anyway, I said too much on such trivial and obvious issue :) -- just
making sure it is clear to you, that is all.

Regards,
Tigran

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



This archive was generated by hypermail 2b29 : Thu Dec 07 2000 - 21:00:08 EST