[lkml]   [2000]   [Dec]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: [PATCH] mutliple root devs (take II)
    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.


    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    Please read the FAQ at

     \ /
      Last update: 2005-03-22 12:49    [W:0.021 / U:5.552 seconds]
    ©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site