From: Manuel Schoelling Subject: Re: [PATCH] fs: Cleanup string initializations (char[] instead of char *) Date: Sun, 18 May 2014 12:01:18 +0200 Message-ID: <1400407278.4698.5.camel@schoellingm.dzne.de> References: <1400338818-2853-1-git-send-email-manuel.schoelling@gmx.de> <20140517165345.GG18016@ZenIV.linux.org.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Anton Altaparmakov To: Al Viro Return-path: In-Reply-To: <20140517165345.GG18016@ZenIV.linux.org.uk> Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org Thanks for the detailed review of my patches, guys! I had a look at the assembler code now, too and you are right about this. I was misguided by the KernelJanitor's TODO list [1]. If there is consensus the corresponding paragraph from that list should be removed. [1] http://kernelnewbies.org/KernelJanitors/Todo On Sa, 2014-05-17 at 17:53 +0100, Al Viro wrote: > On Sat, May 17, 2014 at 05:00:18PM +0200, Manuel Sch=C3=B6lling wrote= : > > Initializations like 'char *foo =3D "bar"' will create two variable= s: 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= ). >=20 > The hell it will. Compare assembler generated e.g. for 32bit x86 bef= ore > and after. >=20 > > { > > char *dp; > > char *status =3D "disabled"; > > - const char * flags =3D "flags: "; > > + const char flags[] =3D "flags: "; >=20 > The first variant puts address of constant array into local variable > (on stack or in a register). The second one fills local _array_ - th= e > string itself goes on stack.