public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: "'trix@redhat.com'" <trix@redhat.com>,
	"toke@toke.dk" <toke@toke.dk>,
	"kvalo@kernel.org" <kvalo@kernel.org>,
	"davem@davemloft.net" <davem@davemloft.net>,
	"kuba@kernel.org" <kuba@kernel.org>,
	"pabeni@redhat.com" <pabeni@redhat.com>
Cc: "linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH] ath9k: initialize arrays at compile time
Date: Sun, 20 Mar 2022 18:46:46 +0000	[thread overview]
Message-ID: <d06ce4fa239645cc9de48c1062f58f14@AcuMS.aculab.com> (raw)
In-Reply-To: <20220320152028.2263518-1-trix@redhat.com>

From: trix@redhat.com <trix@redhat.com>
> Sent: 20 March 2022 15:20
> 
> Early clearing of arrays with
> memset(array, 0, size);
> is equivilent to initializing the array in its decl with
> array[size] = { 0 };
> 
> Since compile time is preferred over runtime,
> convert the memsets to initializations.
...
> diff --git a/drivers/net/wireless/ath/ath9k/ar9003_calib.c
> b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
> index dc24da1ff00b1..39fcc158cb159 100644
> --- 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 };

For a two dimensional array that needs to be {{0}} (or {}).
And, since there is only one definitions of 'coeff' it can
be static!
(Currently on 96 bytes - si not a real problem on-stack.)

Although I just failed to find the lock that stops
concurrent execution on multiple cpu.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)


  parent reply	other threads:[~2022-03-20 18:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-20 15:20 [PATCH] ath9k: initialize arrays at compile time trix
2022-03-20 16:16 ` Joe Perches
2022-03-20 16:48 ` John Crispin
2022-03-20 17:17   ` Sebastian Gottschall
2022-03-20 17:36     ` Joe Perches
2022-03-23 13:13       ` Tom Rix
2022-03-20 17:32   ` Andreas Schwab
2022-03-20 18:46 ` David Laight [this message]
2022-03-21 13:31 ` Toke Høiland-Jørgensen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d06ce4fa239645cc9de48c1062f58f14@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=kvalo@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=toke@toke.dk \
    --cc=trix@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox