lkml.org 
[lkml]   [2022]   [Mar]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] ath9k: initialize arrays at compile time
From
Date
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...



\
 
 \ /
  Last update: 2022-03-20 17:17    [W:0.117 / U:0.052 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site