From: Joe Perches <joe@perches.com>
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
Subject: Re: [PATCH] ath9k: initialize arrays at compile time
Date: Sun, 20 Mar 2022 09:16:26 -0700 [thread overview]
Message-ID: <fea406c589526e45d9f0167628e9925f29a20217.camel@perches.com> (raw)
In-Reply-To: <20220320152028.2263518-1-trix@redhat.com>
On Sun, 2022-03-20 at 08:20 -0700, trix@redhat.com wrote:
> From: Tom Rix <trix@redhat.com>
>
> 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...
next prev parent reply other threads:[~2022-03-20 16:16 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-20 15:20 trix
2022-03-20 16:16 ` Joe Perches [this message]
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
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=fea406c589526e45d9f0167628e9925f29a20217.camel@perches.com \
--to=joe@perches.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
all inboxes | Powered by JetHome®