From mboxrd@z Thu Jan 1 00:00:00 1970 From: Al Viro Subject: Re: [PATCH] fs: Cleanup string initializations (char[] instead of char *) Date: Sat, 17 May 2014 17:53:45 +0100 Message-ID: <20140517165345.GG18016@ZenIV.linux.org.uk> References: <1400338818-2853-1-git-send-email-manuel.schoelling@gmx.de> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org To: Manuel =?iso-8859-1?Q?Sch=F6lling?= Return-path: Content-Disposition: inline In-Reply-To: <1400338818-2853-1-git-send-email-manuel.schoelling@gmx.de> Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org On Sat, May 17, 2014 at 05:00:18PM +0200, Manuel Sch=F6lling wrote: > Initializations like 'char *foo =3D "bar"' will create two variables:= a static > string and a pointer (foo) to that static string. Instead 'char foo[]= =3D "bar"' > will declare a single variable and will end up in shorter > assembly (according to Jeff Garzik on the KernelJanitor's TODO list). The hell it will. Compare assembler generated e.g. for 32bit x86 befor= e and after. > { > char *dp; > char *status =3D "disabled"; > - const char * flags =3D "flags: "; > + const char flags[] =3D "flags: "; The first variant puts address of constant array into local variable (on stack or in a register). The second one fills local _array_ - the string itself goes on stack.