[lkml]   [2001]   [May]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: [PATCH] net #9
    On Wed, 30 May 2001 09:32:39 +0000 (UTC), 
    "Henning P. Schmiedehausen" <> wrote:
    >Andrzej Krzysztofowicz <> writes:
    >>-static char name[4][IFNAMSIZ] = { "", "", "", "" };
    >>+static char name[4][IFNAMSIZ];
    >Ugh. Sure about that one? the variables have been pointers to zero,
    >now they're zero...

    Bzzt. Arrays and pointers are not always equivalent. This code
    defines an area of 4*IFNAMSIZ chars. The old code then initialised
    each IFNAMSIZ chars to the empty string (an array starting with '\0'),
    not a pointer to an empty string. Test file x.c.

    #define IFNAMSIZ 7
    static char name[4][IFNAMSIZ];
    int main(void) { return(0); }

    # gcc -g x.c -o x
    # gdb x
    (gdb) ptype name
    type = char [4][7]
    (gdb) x name[0]
    0x80494f4 <name>: 0x00000000
    (gdb) x name[1]
    0x80494fb <name+7>: 0x00000000
    (gdb) x name[2]
    0x8049502 <name+14>: 0x00000000
    (gdb) x name[3]
    0x8049509 <name+21>: 0x00000000

    Zero initialisation via bss works fine. Try it with
    static char name[4][IFNAMSIZ] = {"", "", "", ""};
    and you get exactly the same results, at the expense of more disk space
    and time to load. Not much extra I know, but it all adds up.

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

     \ /
      Last update: 2005-03-22 12:54    [W:0.020 / U:58.968 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site