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

From: Linus Torvalds
Date: Tue Oct 19 2021 - 02:27:30 EST


On Mon, Oct 18, 2021 at 7:00 PM Nathan Chancellor <nathan@xxxxxxxxxx> wrote:
>
> For what it's worth, the suggested fix is the '||' underneath the
> warning text:
>
> In file included from arch/x86/kvm/mmu/tdp_iter.c:5:
> arch/x86/kvm/mmu/spte.h:318:9: error: use of bitwise '|' with boolean operands [-Werror,-Wbitwise-instead-of-logical]
> return __is_bad_mt_xwr(rsvd_check, spte) |
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ||
> arch/x86/kvm/mmu/spte.h:318:9: note: cast one or both operands to int to silence this warning
> 1 error generated.

Hmm. That's not at all obvious.

The *much* bigger part is that

note: cast one or both operands to int to silence this warning

which is what I'm complaining about. That note should die. It should
say "maybe you meant to use a logical or" or something like that.

> Perhaps that hint should also be added to the warning text, like:
>
> In file included from arch/x86/kvm/mmu/tdp_iter.c:5:
> arch/x86/kvm/mmu/spte.h:318:9: error: use of bitwise '|' with boolean operands; did you mean logical '||'? [-Werror,-Wbitwise-instead-of-logical]
> return __is_bad_mt_xwr(rsvd_check, spte) |
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ||
> arch/x86/kvm/mmu/spte.h:318:9: note: cast one or both operands to int to silence this warning

I don't understand why you seem to continue to ignore the "note"
message, which makes a completely crazy suggestion.

Linus