[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20211018145403.5eb2807d@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com>
Date: Mon, 18 Oct 2021 14:54:03 -0700
From: Jakub Kicinski <kuba@...nel.org>
To: Nathan Chancellor <nathan@...nel.org>
Cc: Simon Horman <simon.horman@...igine.com>,
"David S. Miller" <davem@...emloft.net>,
Nick Desaulniers <ndesaulniers@...gle.com>,
oss-drivers@...igine.com, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org, bpf@...r.kernel.org,
llvm@...ts.linux.dev
Subject: Re: [PATCH] nfp: bpf: Fix bitwise vs. logical OR warning
On Mon, 18 Oct 2021 12:31:01 -0700 Nathan Chancellor wrote:
> A new warning in clang points out two places in this driver where
> boolean expressions are being used with a bitwise OR instead of a
> logical one:
>
> drivers/net/ethernet/netronome/nfp/nfp_asm.c:199:20: error: use of bitwise '|' with boolean operands [-Werror,-Wbitwise-instead-of-logical]
> reg->src_lmextn = swreg_lmextn(lreg) | swreg_lmextn(rreg);
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ||
> drivers/net/ethernet/netronome/nfp/nfp_asm.c:199:20: note: cast one or both operands to int to silence this warning
> drivers/net/ethernet/netronome/nfp/nfp_asm.c:280:20: error: use of bitwise '|' with boolean operands [-Werror,-Wbitwise-instead-of-logical]
> reg->src_lmextn = swreg_lmextn(lreg) | swreg_lmextn(rreg);
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ||
> drivers/net/ethernet/netronome/nfp/nfp_asm.c:280:20: note: cast one or both operands to int to silence this warning
> 2 errors generated.
>
> The motivation for the warning is that logical operations short circuit
> while bitwise operations do not. In this case, it does not seem like
> short circuiting is harmful so implement the suggested fix of changing
> to a logical operation to fix the warning.
Warning seems generally useful, although in this case it is a little
out of place (swreg_lmextn() is a field extractor after all).
Applied to net, but without the Fixes tag, thanks!
Powered by blists - more mailing lists