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 5E243C433F5 for ; Sun, 20 Mar 2022 16:16:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245452AbiCTQSB (ORCPT ); Sun, 20 Mar 2022 12:18:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245449AbiCTQRz (ORCPT ); Sun, 20 Mar 2022 12:17:55 -0400 Received: from relay3.hostedemail.com (relay3.hostedemail.com [64.99.140.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5A534EA1C for ; Sun, 20 Mar 2022 09:16:30 -0700 (PDT) Received: from omf08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 404E023056; Sun, 20 Mar 2022 16:16:29 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf08.hostedemail.com (Postfix) with ESMTPA id A183320029; Sun, 20 Mar 2022 16:16:27 +0000 (UTC) Message-ID: Subject: Re: [PATCH] ath9k: initialize arrays at compile time From: Joe Perches To: 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 09:16:26 -0700 In-Reply-To: <20220320152028.2263518-1-trix@redhat.com> References: <20220320152028.2263518-1-trix@redhat.com> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.40.4-1ubuntu2 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Stat-Signature: dy9osjm7z8ziecmef8cxoawwx5f8z8fy X-Rspamd-Server: rspamout06 X-Rspamd-Queue-Id: A183320029 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX1+fRE9F4p8U535woQ4iQkf2ESmX4XbbijM= X-HE-Tag: 1647792987-69043 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 2022-03-20 at 08:20 -0700, trix@redhat.com wrote: > From: Tom Rix > > Early clearing of arrays with > memset(array, 0, size); > is equivilent to initializing the array in its decl with > array[size] = { 0 }; This is true. (typo of equivalent btw) > Since compile time is preferred over runtime, > convert the memsets to initializations. But this is not. These aren't static but are stack declarations so these can not be "initialized at compile time". Both are zeroed at runtime, perhaps with different instructions. Sometimes with smaller code, sometimes larger. Sometimes faster, sometimes not. Anyway, I think the patch is good, but the commit description is not. > diff --git a/drivers/net/wireless/ath/ath9k/ar9003_calib.c b/drivers/net/wireless/ath/ath9k/ar9003_calib.c [] > @@ -891,10 +891,9 @@ static void ar9003_hw_tx_iq_cal_outlier_detection(struct ath_hw *ah, > { > int i, im, nmeasurement; > int magnitude, phase; > - u32 tx_corr_coeff[MAX_MEASUREMENT][AR9300_MAX_CHAINS]; > + u32 tx_corr_coeff[MAX_MEASUREMENT][AR9300_MAX_CHAINS] = { 0 }; > struct ath9k_hw_cal_data *caldata = ah->caldata; > > - memset(tx_corr_coeff, 0, sizeof(tx_corr_coeff)); etc...