Re: [RFC] cleanup patches for strings

From: Horst von Brand (vonbrand_at_inf.utfsm.cl)
Date: 06/21/05

  • Next message: Steve French: "Re: [RFC] [PATCH] OCFS2"
    To: Jesper Juhl <juhl-lkml@dif.dk>
    Date:	Tue, 21 Jun 2005 17:12:16 -0400
    
    

    Jesper Juhl <juhl-lkml@dif.dk> wrote:
    > I have a bunch (few hundred) of oneliners like the ones below lying around
    > on my HD and I'm wondering what the best way to submit them is.
    >
    > The patches all make the same change, there's just a lot of files the
    > change needs to be made in. The change they make is to change strings
    > from the form
    > [const] char *foo = "blah";
    > to
    > [const] char foo[] = "blah";
    >
    > The reason to do this was well explained by Jeff Garzik in the past (and
    > now found in the Kernel Janitors TODO) :

    Which is dead wrong. A short test program here (Fedora rawhide, i686,
    gcc-4.0.0) shows that if you use an array, it is allocated on the stack and
    the contents of the (constant, readonly) string is copied there before use,
    just as you'd have to expect given C's semantics. I.e., the function gets
    larger, slower, and uses more stack. If the array is declared const makes
    no difference (AFAIR, it can't, as the const doesn't guarantee it won't be
    changed).

    -- 
    Dr. Horst H. von Brand                   User #22616 counter.li.org
    Departamento de Informatica                     Fono: +56 32 654431
    Universidad Tecnica Federico Santa Maria              +56 32 654239
    Casilla 110-V, Valparaiso, Chile                Fax:  +56 32 797513
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at  http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at  http://www.tux.org/lkml/
    

  • Next message: Steve French: "Re: [RFC] [PATCH] OCFS2"

    Relevant Pages

    • Re: Sparse warning: bitmap.h: bad constant expression
      ... a variable-length array is _exactly_ the same as the historic "alloca" ... fact that one generates a pointer and the other generates an array). ... "objdump + grep" approach for finding bad stack users. ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: I dont understand the definition of DOES>
      ... on stack on code entry). ... You can use DOES to make ARRAY and then use ARRAY ... CREATE CELLS ALLOT ... First you'd make the code that will execute on the child word. ...
      (comp.lang.forth)
    • how does your language... make a map?
      ... "include"ed in the interpreter for testing. ... Since Forth uses a Last-in-First-out implicit stack, ... variable cols ... I want to create an array that will in the future contain all the ...
      (rec.games.roguelike.development)
    • Re: Globally declared arrays
      ... I noticed that my colleague was declaring local arrays on the stack, ... What is a "global array on ...
      (comp.lang.c)
    • Re: Use of PICK and ROLL
      ... An array, in contrast, may be accessed at any point: ... PICK and ROLL are therefore array operations, not stack ... I thuoght the point was that if you needed to change the search order ...
      (comp.lang.forth)