Linux wireless drivers development
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Joe Perches' <joe@perches.com>,
	Anders Roxell <anders.roxell@linaro.org>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"woojung.huh@microchip.com" <woojung.huh@microchip.com>,
	"UNGLinuxDriver@microchip.com" <UNGLinuxDriver@microchip.com>,
	"davem@davemloft.net" <davem@davemloft.net>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"clang-built-linux@googlegroups.com" 
	<clang-built-linux@googlegroups.com>,
	"ulli.kroll@googlemail.com" <ulli.kroll@googlemail.com>,
	"linux@armlinux.org.uk" <linux@armlinux.org.uk>,
	"linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>,
	"amitkarwar@gmail.com" <amitkarwar@gmail.com>,
	"nishants@marvell.com" <nishants@marvell.com>,
	"gbhat@marvell.com" <gbhat@marvell.com>,
	"huxinming820@gmail.com" <huxinming820@gmail.com>,
	"kvalo@codeaurora.org" <kvalo@codeaurora.org>,
	"linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>,
	"rostedt@goodmis.org" <rostedt@goodmis.org>,
	"mingo@redhat.com" <mingo@redhat.com>,
	"dmitry.torokhov@gmail.com" <dmitry.torokhov@gmail.com>,
	"ndesaulniers@google.com" <ndesaulniers@google.com>,
	"nathan@kernel.org" <nathan@kernel.org>,
	"linux-input@vger.kernel.org" <linux-input@vger.kernel.org>,
	Nathan Chancellor <natechancellor@gmail.com>,
	Andy Lavr <andy.lavr@gmail.com>
Subject: RE: [PATCH 4.19 3/6] mwifiex: Remove unnecessary braces from HostCmd_SET_SEQ_NO_BSS_INFO
Date: Mon, 20 Dec 2021 14:00:40 +0000	[thread overview]
Message-ID: <5797d1aff9034476afa6827af2bfbce7@AcuMS.aculab.com> (raw)
In-Reply-To: <bc4a4ba7c07a4077b9790be883fb4205d401804e.camel@perches.com>

From: Joe Perches
> Sent: 20 December 2021 12:13
> 
> On Fri, 2021-12-17 at 15:41 +0100, Anders Roxell wrote:
> > From: Nathan Chancellor <natechancellor@gmail.com>
> >
> > commit 6a953dc4dbd1c7057fb765a24f37a5e953c85fb0 upstream.
> >
> > A new warning in clang points out when macro expansion might result in a
> > GNU C statement expression. There is an instance of this in the mwifiex
> > driver:
> >
> > drivers/net/wireless/marvell/mwifiex/cmdevt.c:217:34: warning: '}' and
> > ')' tokens terminating statement expression appear in different macro
> > expansion contexts [-Wcompound-token-split-by-macro]
> >         host_cmd->seq_num = cpu_to_le16(HostCmd_SET_SEQ_NO_BSS_INFO
> >                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
> []
> > diff --git a/drivers/net/wireless/marvell/mwifiex/fw.h b/drivers/net/wireless/marvell/mwifiex/fw.h
> []
> > @@ -512,10 +512,10 @@ enum mwifiex_channel_flags {
> >
> >  #define RF_ANTENNA_AUTO                 0xFFFF
> >
> > -#define HostCmd_SET_SEQ_NO_BSS_INFO(seq, num, type) {   \
> > -	(((seq) & 0x00ff) |                             \
> > -	 (((num) & 0x000f) << 8)) |                     \
> > -	(((type) & 0x000f) << 12);                  }
> > +#define HostCmd_SET_SEQ_NO_BSS_INFO(seq, num, type) \
> > +	((((seq) & 0x00ff) |                        \
> > +	 (((num) & 0x000f) << 8)) |                 \
> > +	(((type) & 0x000f) << 12))
> 
> Perhaps this would be better as a static inline
> 
> static inline u16 HostCmd_SET_SEQ_NO_BSS_INFO(u16 seq, u8 num, u8 type)
> {
> 	return (type & 0x000f) << 12 | (num & 0x000f) << 8 | (seq & 0x00ff);
> }

Just writing in on one line helps readability!
It is also used exactly twice, both with a cpu_to_le16().
I wonder how well the compiler handles that on BE?
The #define is more likely to be handled better.

I've only made a cursory glance at the code, but I get splitting
host_cmd->seq_num into two u8 fields would give better code!

	David

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


  reply	other threads:[~2021-12-20 14:00 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-17 14:41 [PATCH 4.19 0/6] fix warning and errors on arm built with clang Anders Roxell
2021-12-17 14:41 ` [PATCH 4.19 1/6] net: lan78xx: Avoid unnecessary self assignment Anders Roxell
2021-12-17 14:41 ` [PATCH 4.19 2/6] ARM: 8805/2: remove unneeded naked function usage Anders Roxell
2021-12-17 14:41 ` [PATCH 4.19 3/6] mwifiex: Remove unnecessary braces from HostCmd_SET_SEQ_NO_BSS_INFO Anders Roxell
2021-12-20 10:56   ` Greg KH
2021-12-20 12:13   ` Joe Perches
2021-12-20 14:00     ` David Laight [this message]
2021-12-17 14:41 ` [PATCH 4.19 4/6] ARM: 8800/1: use choice for kernel unwinders Anders Roxell
2021-12-17 14:41 ` [PATCH 4.19 5/6] ARM: 8788/1: ftrace: remove old mcount support Anders Roxell
2021-12-20 10:57   ` Greg KH
2022-01-11 20:58     ` Stefan Agner
2022-01-11 21:04   ` Nick Desaulniers
2021-12-17 14:41 ` [PATCH 4.19 6/6] Input: touchscreen - avoid bitwise vs logical OR warning Anders Roxell
2021-12-20 10:59   ` Greg KH
2021-12-21 12:24     ` Anders Roxell

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=5797d1aff9034476afa6827af2bfbce7@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=amitkarwar@gmail.com \
    --cc=anders.roxell@linaro.org \
    --cc=andy.lavr@gmail.com \
    --cc=clang-built-linux@googlegroups.com \
    --cc=davem@davemloft.net \
    --cc=dmitry.torokhov@gmail.com \
    --cc=gbhat@marvell.com \
    --cc=huxinming820@gmail.com \
    --cc=joe@perches.com \
    --cc=kvalo@codeaurora.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=mingo@redhat.com \
    --cc=natechancellor@gmail.com \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=nishants@marvell.com \
    --cc=rostedt@goodmis.org \
    --cc=stable@vger.kernel.org \
    --cc=ulli.kroll@googlemail.com \
    --cc=woojung.huh@microchip.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