From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5E621C433EF for ; Sun, 20 Mar 2022 17:37:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245735AbiCTRh4 (ORCPT ); Sun, 20 Mar 2022 13:37:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229713AbiCTRhv (ORCPT ); Sun, 20 Mar 2022 13:37:51 -0400 Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.26]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60644187B8D for ; Sun, 20 Mar 2022 10:36:26 -0700 (PDT) Received: from omf01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id C6B39808CD; Sun, 20 Mar 2022 17:36:24 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf01.hostedemail.com (Postfix) with ESMTPA id 06E7A6000F; Sun, 20 Mar 2022 17:36:22 +0000 (UTC) Message-ID: <7a12fd4599758b8cd5fd376db6c9a950d2ed2094.camel@perches.com> Subject: Re: [PATCH] ath9k: initialize arrays at compile time From: Joe Perches To: Sebastian Gottschall , John Crispin , trix@redhat.com, toke@toke.dk, kvalo@kernel.org, davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com Cc: linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Date: Sun, 20 Mar 2022 10:36:22 -0700 In-Reply-To: <233074c3-03dc-cf8b-a597-da0fb5d98be0@newmedia-net.de> References: <20220320152028.2263518-1-trix@redhat.com> <233074c3-03dc-cf8b-a597-da0fb5d98be0@newmedia-net.de> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.40.4-1ubuntu2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspamout05 X-Rspamd-Queue-Id: 06E7A6000F X-Stat-Signature: kyhb7gnh49rf5g8afdop8akper1tfctj X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX1+MWWQV3UpfM7ndNnHlITLS7MbzcF0w6oI= X-HE-Tag: 1647797782-48345 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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@redhat.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.