From: Simon Horman <simon.horman@netronome.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Nathan Chancellor <natechancellor@gmail.com>,
Johannes Berg <johannes@sipsolutions.net>,
linux-wireless <linux-wireless@vger.kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Networking <netdev@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
clang-built-linux@googlegroups.com,
Nick Desaulniers <ndesaulniers@google.com>
Subject: Re: [PATCH] cfg80211: Change an 'else if' into an 'else' in cfg80211_calculate_bitrate_he
Date: Tue, 26 Mar 2019 10:36:00 +0100 [thread overview]
Message-ID: <20190326093558.ymokh5xxyww2dti5@netronome.com> (raw)
In-Reply-To: <CAK8P3a1vsJ9qUg_p0UN_xSmYupApY++J8ZP2frmYR7Ja3Hc4iQ@mail.gmail.com>
On Fri, Mar 22, 2019 at 03:16:06PM +0100, Arnd Bergmann wrote:
> On Fri, Mar 8, 2019 at 12:57 AM Nathan Chancellor
> <natechancellor@gmail.com> wrote:
> >
> > When building with -Wsometimes-uninitialized, Clang warns:
> >
> > net/wireless/util.c:1223:11: warning: variable 'result' is used
> > uninitialized whenever 'if' condition is false
> > [-Wsometimes-uninitialized]
> >
> > Clang can't evaluate at this point that WARN(1, ...) always returns true
> > because __ret_warn_on is defined as !!(condition), which isn't
> > immediately evaluated as 1. Change this branch to else so that it's
> > clear to Clang that we intend to bail out here.
> >
> > Link: https://github.com/ClangBuiltLinux/linux/issues/382
> > Suggested-by: Nick Desaulniers <ndesaulniers@google.com>
> > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> > ---
> > net/wireless/util.c | 6 ++++--
> > 1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/net/wireless/util.c b/net/wireless/util.c
> > index e4b8db5e81ec..75899b62bdc9 100644
> > --- a/net/wireless/util.c
> > +++ b/net/wireless/util.c
> > @@ -1220,9 +1220,11 @@ static u32 cfg80211_calculate_bitrate_he(struct rate_info *rate)
> > else if (rate->bw == RATE_INFO_BW_HE_RU &&
> > rate->he_ru_alloc == NL80211_RATE_INFO_HE_RU_ALLOC_26)
> > result = rates_26[rate->he_gi];
> > - else if (WARN(1, "invalid HE MCS: bw:%d, ru:%d\n",
> > - rate->bw, rate->he_ru_alloc))
> > + else {
> > + WARN(1, "invalid HE MCS: bw:%d, ru:%d\n",
> > + rate->bw, rate->he_ru_alloc);
> > return 0;
> > + }
>
> Reviewed-by: Arnd Bergmann <arnd@arndb.de>
>
> I independently came up with the same fix before I saw yours,
> the only difference was that I avoided the extra curly braces
> using
>
> + else
> + return !WARN(1, "invalid HE MCS: bw:%d, ru:%d\n",
> + rate->bw, rate->he_ru_alloc);
>
> to avoid the mix of bare if() and if() {}
Right, shouldn't all arms of the if/else if/else conditional have {}
if any arm has {}.
prev parent reply other threads:[~2019-03-26 9:36 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-07 23:57 Nathan Chancellor
2019-03-08 0:10 ` Nick Desaulniers
2019-03-20 19:10 ` Nathan Chancellor
2019-03-22 14:16 ` Arnd Bergmann
2019-03-26 9:36 ` Simon Horman [this message]
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=20190326093558.ymokh5xxyww2dti5@netronome.com \
--to=simon.horman@netronome.com \
--cc=arnd@arndb.de \
--cc=clang-built-linux@googlegroups.com \
--cc=davem@davemloft.net \
--cc=johannes@sipsolutions.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=natechancellor@gmail.com \
--cc=ndesaulniers@google.com \
--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 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®