lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Wed, 23 Mar 2022 06:13:25 -0700 From: Tom Rix <trix@...hat.com> To: Joe Perches <joe@...ches.com>, Sebastian Gottschall <s.gottschall@...media-net.de>, John Crispin <john@...ozen.org>, toke@...e.dk, kvalo@...nel.org, davem@...emloft.net, kuba@...nel.org, pabeni@...hat.com Cc: linux-wireless@...r.kernel.org, netdev@...r.kernel.org, linux-kernel@...r.kernel.org Subject: Re: [PATCH] ath9k: initialize arrays at compile time On 3/20/22 10:36 AM, Joe Perches wrote: > On Sun, 2022-03-20 at 18:17 +0100, Sebastian Gottschall wrote: >> Am 20.03.2022 um 17:48 schrieb John Crispin: >>> >>> On 20.03.22 16:20, trix@...hat.com wrote: >>>> array[size] = { 0 }; >>> should this not be array[size] = { }; ?! >>> >>> If I recall correctly { 0 } will only set the first element of the >>> struct/array to 0 and leave random data in all others elements >>> >>> John >> You are right, john > No. The patch is fine. > > Though generally the newer code in the kernel uses > > type dec[size] = {}; > > to initialize stack arrays. > > array stack declarations not using 0 > > $ git grep -P '^\t(?:\w++\s*){1,2}\[\s*\w+\s*\]\s*=\s*\{\s*\};' -- '*.c' | wc -l > 213 > > array stack declarations using 0 > > $ git grep -P '^\t(?:\w++\s*){1,2}\[\s*\w+\s*\]\s*=\s*\{\s*0\s*\};' -- '*.c' | wc -l > 776 > > Refer to the c standard section on initialization 6.7.8 subsections 19 and 21 > > 19 > > The initialization shall occur in initializer list order, each initializer provided for a > particular subobject overriding any previously listed initializer for the same subobject > all subobjects that are not initialized explicitly shall be initialized implicitly the same as > objects that have static storage duration. > > ... > > 21 > > If there are fewer initializers in a brace-enclosed list than there are elements or members > of an aggregate, or fewer characters in a string literal used to initialize an array of known > size than there are elements in the array, the remainder of the aggregate shall be > initialized implicitly the same as objects that have static storage duration. > Joe, Thanks for providing these sections for c reference ! I will update the commit log and replace { 0 } with { } Tom
Powered by blists - more mailing lists