Re: [RFC] cleanup patches for strings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jesper Juhl <[email protected]> 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 [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux