All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kalle Valo <kvalo@codeaurora.org>
To: Lee Jones <lee.jones@linaro.org>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	Christian Lamparter <chunkeey@gmail.com>,
	davem@davemloft.net, kuba@kernel.org,
	linux-kernel@vger.kernel.org,
	Christian Lamparter <chunkeey@googlemail.com>,
	Johannes Berg <johannes@sipsolutions.net>,
	linux-wireless@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH 08/30] net: wireless: ath: carl9170: Mark 'ar9170_qmap' as __maybe_unused
Date: Thu, 27 Aug 2020 10:54:21 +0300	[thread overview]
Message-ID: <87r1rsle1e.fsf@codeaurora.org> (raw)
In-Reply-To: <20200818095024.GZ4354@dell> (Lee Jones's message of "Tue, 18 Aug 2020 10:50:24 +0100")

Lee Jones <lee.jones@linaro.org> writes:

> On Mon, 17 Aug 2020, Kalle Valo wrote:
>
>> Rasmus Villemoes <linux@rasmusvillemoes.dk> writes:
>> 
>> > On 14/08/2020 17.14, Christian Lamparter wrote:
>> >> On 2020-08-14 13:39, Lee Jones wrote:
>> >>> 'ar9170_qmap' is used in some source files which include carl9170.h,
>> >>> but not all of them.  Mark it as __maybe_unused to show that this is
>> >>> not only okay, it's expected.
>> >>>
>> >>> Fixes the following W=1 kernel build warning(s)
>> >> 
>> >> Is this W=1 really a "must" requirement? I find it strange having
>> >> __maybe_unused in header files as this "suggests" that the
>> >> definition is redundant.
>> >
>> > In this case it seems one could replace the table lookup with a
>> >
>> > static inline u8 ar9170_qmap(u8 idx) { return 3 - idx; }
>> >
>> > gcc doesn't warn about unused static inline functions (or one would have
>> > a million warnings to deal with). Just my $0.02.
>> 
>> Yeah, this is much better.
>> 
>> And I think that static variables should not even be in the header
>> files. Doesn't it mean that there's a local copy of the variable
>> everytime the .h file is included? Sure, in this case the overhead is
>> small (4 bytes per include) but still it's wrong.
>
> It happens a lot.
>
> As I stated before, the 2 viable options are to a) move it into the
> source files; ensuring code duplication, unnecessary maintenance
> burden and probably disparity over time, or b) create (or locate if
> there is one already) a special header file which is only to be
> included by the users.
>
> The later option gets really complicated if there are a variety of
> tables which are included by any given number of source file
> permutations.
>
> The accepted answer in all of the other subsystems I've worked with so
> far, is to use __maybe_unused.  It's simple, non-intrusive and doesn't
> rely on any functional changes.
>
>> Having a static inline
>> function would solve that problem as well the compiler warning.
>
> This time yes, but it's a hack that will only work with simple,
> linear data.  

To me __maybe_unused is a hack and a static inline function is a much
better solution.

> Try doing that with some of the other, more complicated
> tables, like mwifiex_sdio_sd8*.

Then the table should be moved to a .c file and the .h file should have
"extern const int foo[]"

-- 
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

  reply	other threads:[~2020-08-27  7:55 UTC|newest]

Thread overview: 85+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-14 11:39 [PATCH 00/30] Rid W=1 warnings in Networking Lee Jones
2020-08-14 11:39 ` [PATCH 01/30] net: bonding: bond_3ad: Fix a bunch of kerneldoc parameter issues Lee Jones
2020-08-14 11:39 ` [PATCH 02/30] net: bonding: bond_main: Document 'proto' and rename 'new_active' parameters Lee Jones
2020-08-14 11:39 ` [PATCH 03/30] net: ethernet: 3com: 3c574_cs: Remove set but unused variables 'tx' and 'rx' Lee Jones
2020-08-14 11:39 ` [PATCH 04/30] net: bonding: bond_alb: Describe alb_handle_addr_collision_on_attach()'s 'bond' and 'addr' params Lee Jones
2020-08-14 11:39 ` [PATCH 05/30] net: wireless: atmel: atmel: Demote non-kerneldoc header to standard comment block Lee Jones
2020-08-27 12:16   ` [PATCH 05/30] " Kalle Valo
2020-08-14 11:39 ` [PATCH 06/30] net: ethernet: 8390: axnet_cs: Document unused parameter 'txqueue' Lee Jones
2020-08-14 11:39 ` [PATCH 07/30] net: wireless: broadcom: b43: main: Add braces around empty statements Lee Jones
2020-08-14 11:39   ` Lee Jones
2020-08-14 15:12   ` Kalle Valo
2020-08-14 15:12     ` Kalle Valo
2020-08-14 16:43     ` Lee Jones
2020-08-14 16:43       ` Lee Jones
2020-08-14 17:25       ` Kalle Valo
2020-08-14 17:25         ` Kalle Valo
2020-08-17  8:50         ` Lee Jones
2020-08-17  8:50           ` Lee Jones
2020-08-27  7:42           ` Kalle Valo
2020-08-27  7:42             ` Kalle Valo
2020-08-27  8:49             ` Lee Jones
2020-08-27  8:49               ` Lee Jones
2020-08-14 11:39 ` [PATCH 08/30] net: wireless: ath: carl9170: Mark 'ar9170_qmap' as __maybe_unused Lee Jones
2020-08-14 15:14   ` Christian Lamparter
2020-08-14 16:40     ` Lee Jones
2020-08-14 17:25       ` Christian Lamparter
2020-08-17  8:43         ` Lee Jones
2020-08-17  8:26     ` Rasmus Villemoes
2020-08-17 12:59       ` Kalle Valo
2020-08-17 18:29         ` Christian Lamparter
2020-08-18  9:50         ` Lee Jones
2020-08-27  7:54           ` Kalle Valo [this message]
2020-08-27  9:33   ` [PATCH v2 08/30] net: wireless: ath: carl9170: Convert 'ar9170_qmap' to inline function Lee Jones
2020-08-28 20:28     ` Christian Lamparter
2020-08-31 13:56       ` Kalle Valo
2020-08-31 15:19     ` Kalle Valo
2020-08-14 11:39 ` [PATCH 09/30] net: wireless: ath: ath5k: pcu: Add a description for 'band' remove one for 'mode' Lee Jones
2020-08-17 10:20   ` Kalle Valo
2020-08-14 11:39 ` [PATCH 10/30] net: wan: dlci: Remove set but not used variable 'err' Lee Jones
2020-08-14 11:39 ` [PATCH 11/30] net: wireless: cisco: airo: Place brackets around empty statement Lee Jones
2020-08-14 11:39 ` [PATCH 12/30] net: wireless: cisco: airo: Fix a myriad of coding style issues Lee Jones
2020-08-14 15:15   ` Kalle Valo
2020-08-14 16:38     ` Lee Jones
2020-08-17 13:27       ` Kalle Valo
2020-08-17 18:27         ` Jesse Brandeburg
2020-08-17 20:04           ` Lee Jones
2020-08-17 21:35           ` Ondrej Zary
2020-08-27  7:49             ` Kalle Valo
2020-08-27 20:23               ` Ondrej Zary
2020-08-28  8:59                 ` Kalle Valo
2020-08-28 10:08                   ` Lee Jones
2020-08-28 12:37                     ` Kalle Valo
2020-08-28 21:34                   ` Ondrej Zary
2020-08-14 11:39 ` [PATCH 13/30] net: wireless: ath: wil6210: cfg80211: Demote non-kerneldoc headers to standard comment blocks Lee Jones
2020-08-14 11:39 ` [PATCH 14/30] net: wireless: intel: iwlegacy: common: Remove set but not used variable 'len' Lee Jones
2020-08-14 11:39 ` [PATCH 15/30] net: wireless: intel: iwlegacy: common: Demote kerneldoc headers to standard comment blocks Lee Jones
2020-08-14 11:39 ` [PATCH 16/30] net: wireless: intel: ipw2200: Remove set but unused variables 'rc' and 'w' Lee Jones
2020-08-14 11:39 ` [PATCH 17/30] net: wireless: broadcom: b43legacy: main: Provide braces around empty 'if' body Lee Jones
2020-08-14 11:39   ` Lee Jones
2020-08-14 11:39 ` [PATCH 18/30] net: fddi: skfp: hwmtm: Remove seemingly unused variable 'ID_sccs' Lee Jones
2020-08-14 11:39 ` [PATCH 19/30] net: fddi: skfp: fplustm: " Lee Jones
2020-08-14 11:39 ` [PATCH 20/30] net: wireless: ath: ath5k: base: Fix kerneldoc formatting issue Lee Jones
2020-08-14 11:39 ` [PATCH 21/30] net: fddi: skfp: smt: Place definition of 'smt_pdef' under same stipulations as its use Lee Jones
2020-08-14 11:39 ` [PATCH 22/30] net: wireless: broadcom: brcm80211: brcmfmac: fweh: Remove set but unused variable 'err' Lee Jones
2020-08-14 11:39 ` [PATCH 23/30] net: wireless: broadcom: brcm80211: brcmfmac: fweh: Fix docrot related function documentation issues Lee Jones
2020-08-14 11:39 ` [PATCH 24/30] net: wireless: broadcom: brcm80211: brcmsmac: mac80211_if: Demote a few non-conformant kerneldoc headers Lee Jones
2020-08-14 11:39 ` [PATCH 25/30] net: wireless: intel: ipw2x00: ipw2200: Demote lots of nonconformant kerneldoc comments Lee Jones
2020-08-14 11:39 ` [PATCH 26/30] net: wireless: broadcom: b43: phy_common: Demote non-conformant kerneldoc header Lee Jones
2020-08-14 11:39   ` Lee Jones
     [not found]   ` <CAJrvBf00yQQ7F1p1utBuq1oWc2RwnqXijBjaJ+FuxG0mS0TvOA@mail.gmail.com>
2020-08-14 16:36     ` Lee Jones
2020-08-14 16:36       ` Lee Jones
2020-08-17  8:06   ` Rafał Miłecki
2020-08-17  8:06     ` Rafał Miłecki
2020-08-17  9:11     ` Lee Jones
2020-08-17  9:11       ` Lee Jones
2020-08-14 11:39 ` [PATCH 27/30] net: fddi: skfp: smt: Remove seemingly unused variable 'ID_sccs' Lee Jones
2020-08-14 11:39 ` [PATCH 28/30] net: fddi: skfp: cfm: Remove set but unused variable 'oldstate' Lee Jones
2020-08-14 11:39 ` [PATCH 29/30] net: fddi: skfp: cfm: Remove seemingly unused variable 'ID_sccs' Lee Jones
2020-08-14 11:39 ` [PATCH 30/30] net: wireless: broadcom: b43: phy_n: Add empty braces around empty statements Lee Jones
2020-08-14 11:39   ` Lee Jones
2020-08-15  3:42 ` [PATCH 00/30] Rid W=1 warnings in Networking David Miller
2020-08-17  9:26   ` Lee Jones
2020-08-17 19:02     ` David Miller
2020-08-17 19:58       ` Lee Jones
     [not found] ` <87eeo88pdr.fsf@tynnyri.adurom.net>
2020-08-17  8:16   ` Lee Jones

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=87r1rsle1e.fsf@codeaurora.org \
    --to=kvalo@codeaurora.org \
    --cc=chunkeey@gmail.com \
    --cc=chunkeey@googlemail.com \
    --cc=davem@davemloft.net \
    --cc=johannes@sipsolutions.net \
    --cc=kuba@kernel.org \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=netdev@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.