lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20190326093558.ymokh5xxyww2dti5@netronome.com>
Date:   Tue, 26 Mar 2019 10:36:00 +0100
From:   Simon Horman <simon.horman@...ronome.com>
To:     Arnd Bergmann <arnd@...db.de>
Cc:     Nathan Chancellor <natechancellor@...il.com>,
        Johannes Berg <johannes@...solutions.net>,
        linux-wireless <linux-wireless@...r.kernel.org>,
        "David S. Miller" <davem@...emloft.net>,
        Networking <netdev@...r.kernel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        clang-built-linux@...glegroups.com,
        Nick Desaulniers <ndesaulniers@...gle.com>
Subject: Re: [PATCH] cfg80211: Change an 'else if' into an 'else' in
 cfg80211_calculate_bitrate_he

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@...il.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@...gle.com>
> > Signed-off-by: Nathan Chancellor <natechancellor@...il.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@...db.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 {}.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ