Re: [PATCH] platform/x86: thinkpad_acpi: Fix bitwise vs. logical warning

From: Nick Desaulniers
Date: Mon Oct 18 2021 - 16:14:20 EST


On Mon, Oct 18, 2021 at 12:41 PM Linus Torvalds
<torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> On Mon, Oct 18, 2021 at 8:34 AM Nick Desaulniers
> <ndesaulniers@xxxxxxxxxx> wrote:
> >
> > LGTM, thanks for the patch! I guess this would be the first
> > "interesting" case this warning has found in kernel sources?
>
> The patch looks obviously correct (tm), but I'm not convinced that the
> warning is actually all that interesting.
>
> The thing is, using bitwise operators for booleans is _exactly_ the
> same as using logical ones as long as there are no side effects.

Right, the patch that added the warning explicitly checks for side effects.
https://reviews.llvm.org/D108003
https://lore.kernel.org/lkml/20211018193101.2340261-1-nathan@xxxxxxxxxx/
is another example that I would point to in favor of the error.
--
Thanks,
~Nick Desaulniers