public inbox for linux-wireless@vger.kernel.org
 help / color / mirror / Atom feed
From: Stanislaw Gruszka <stf_xl@wp.pl>
To: Arnd Bergmann <arnd@kernel.org>
Cc: Johannes Berg <johannes@sipsolutions.net>,
	Arnd Bergmann <arnd@arndb.de>, Kalle Valo <kvalo@kernel.org>,
	Ben Hutchings <ben@decadent.org.uk>,
	"Dr. David Alan Gilbert" <linux@treblig.org>,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>,
	linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] [v2] iwlegacy: don't warn for unused variables with DEBUG_FS=n
Date: Sat, 1 Mar 2025 13:28:34 +0100	[thread overview]
Message-ID: <20250301122834.GA55739@wp.pl> (raw)
In-Reply-To: <20250225145359.1126786-1-arnd@kernel.org>

On Tue, Feb 25, 2025 at 03:53:53PM +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> The reference to il_rate_mcs is inside of an #ifdef, causing a W=1 warning:
> 
> drivers/net/wireless/intel/iwlegacy/4965-rs.c:189:38: error: unused variable 'il_rate_mcs' [-Werror,-Wunused-const-variable]
> static const struct il_rate_mcs_info il_rate_mcs[RATE_COUNT] = {
> 
> Replace the #ifdef with a PTR_IF() for better compile time analysis.
> The dead code will still get eliminated, but the warning goes away.

But then the code will be compiled for !CONFIG_MAC80211_DEBUGFS
case, it does compile for me:

-  22475	   1160	      0	  23635	   5c53	drivers/net/wireless/intel/iwlegacy/4965-rs.o
+  23008	   1168	      0	  24176	   5e70	drivers/net/wireless/intel/iwlegacy/4965-rs.o

How about moving  
static const struct il_rate_mcs_info il_rate_mcs[RATE_COUNT]
under CONFIG_MAC80211_DEBUGFS ? Maybe inside the function that use it ? 

Regards
Stanislaw

> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> v2: use correct config symbol consistently
> ---
>  drivers/net/wireless/intel/iwlegacy/4965-rs.c | 15 ++-------------
>  drivers/net/wireless/intel/iwlegacy/common.h  |  2 --
>  2 files changed, 2 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/net/wireless/intel/iwlegacy/4965-rs.c b/drivers/net/wireless/intel/iwlegacy/4965-rs.c
> index 718efb1aa1b0..f754fb979546 100644
> --- a/drivers/net/wireless/intel/iwlegacy/4965-rs.c
> +++ b/drivers/net/wireless/intel/iwlegacy/4965-rs.c
> @@ -132,15 +132,8 @@ static void il4965_rs_fill_link_cmd(struct il_priv *il,
>  static void il4965_rs_stay_in_table(struct il_lq_sta *lq_sta,
>  				    bool force_search);
>  
> -#ifdef CONFIG_MAC80211_DEBUGFS
>  static void il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta,
>  				    u32 *rate_n_flags, int idx);
> -#else
> -static void
> -il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, u32 * rate_n_flags, int idx)
> -{
> -}
> -#endif
>  
>  /*
>   * The following tables contain the expected throughput metrics for all rates
> @@ -2495,8 +2488,6 @@ il4965_rs_free_sta(void *il_r, struct ieee80211_sta *sta, void *il_sta)
>  	D_RATE("leave\n");
>  }
>  
> -#ifdef CONFIG_MAC80211_DEBUGFS
> -
>  static void
>  il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, u32 * rate_n_flags, int idx)
>  {
> @@ -2758,7 +2749,6 @@ il4965_rs_add_debugfs(void *il, void *il_sta, struct dentry *dir)
>  	debugfs_create_u8("tx_agg_tid_enable", 0600, dir,
>  			  &lq_sta->tx_agg_tid_en);
>  }
> -#endif
>  
>  /*
>   * Initialization of rate scaling information is done by driver after
> @@ -2781,9 +2771,8 @@ static const struct rate_control_ops rs_4965_ops = {
>  	.free = il4965_rs_free,
>  	.alloc_sta = il4965_rs_alloc_sta,
>  	.free_sta = il4965_rs_free_sta,
> -#ifdef CONFIG_MAC80211_DEBUGFS
> -	.add_sta_debugfs = il4965_rs_add_debugfs,
> -#endif
> +	.add_sta_debugfs = PTR_IF(IS_ENABLED(CONFIG_MAC80211_DEBUGFS),
> +				  il4965_rs_add_debugfs),
>  };
>  
>  int
> diff --git a/drivers/net/wireless/intel/iwlegacy/common.h b/drivers/net/wireless/intel/iwlegacy/common.h
> index 92285412ab10..52610f5e57a3 100644
> --- a/drivers/net/wireless/intel/iwlegacy/common.h
> +++ b/drivers/net/wireless/intel/iwlegacy/common.h
> @@ -2815,9 +2815,7 @@ struct il_lq_sta {
>  	struct il_scale_tbl_info lq_info[LQ_SIZE];	/* "active", "search" */
>  	struct il_traffic_load load[TID_MAX_LOAD_COUNT];
>  	u8 tx_agg_tid_en;
> -#ifdef CONFIG_MAC80211_DEBUGFS
>  	u32 dbg_fixed_rate;
> -#endif
>  	struct il_priv *drv;
>  
>  	/* used to be in sta_info */
> -- 
> 2.39.5
> 

  reply	other threads:[~2025-03-01 12:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-25 14:53 [PATCH] [v2] iwlegacy: don't warn for unused variables with DEBUG_FS=n Arnd Bergmann
2025-03-01 12:28 ` Stanislaw Gruszka [this message]
2025-03-01 12:38   ` Arnd Bergmann
2025-03-01 13:36     ` Stanislaw Gruszka
2025-03-01 13:49       ` Arnd Bergmann
2025-03-01 18:02         ` Stanislaw Gruszka

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=20250301122834.GA55739@wp.pl \
    --to=stf_xl@wp.pl \
    --cc=arnd@arndb.de \
    --cc=arnd@kernel.org \
    --cc=ben@decadent.org.uk \
    --cc=gustavoars@kernel.org \
    --cc=johannes@sipsolutions.net \
    --cc=kvalo@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linux@treblig.org \
    /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