[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAKwvOdmy6Fo-FvximsRN+i0sZ5ZgWjWdD-m2fLN-rhvBuqO9mw@mail.gmail.com>
Date: Tue, 16 Nov 2021 10:16:22 -0800
From: Nick Desaulniers <ndesaulniers@...gle.com>
To: Paolo Bonzini <pbonzini@...hat.com>,
David Bolvansky <david.bolvansky@...il.com>
Cc: Vitaly Kuznetsov <vkuznets@...hat.com>,
Vihas Mak <makvihas@...il.com>, seanjc@...gle.com,
wanpengli@...cent.com, jmattson@...gle.com, joro@...tes.org,
tglx@...utronix.de, mingo@...hat.com, bp@...en8.de,
dave.hansen@...ux.intel.com, x86@...nel.org, hpa@...or.com,
kvm@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] KVM: x86: fix cocci warnings
On Tue, Nov 16, 2021 at 1:50 AM Paolo Bonzini <pbonzini@...hat.com> wrote:
>
> On 11/15/21 10:59, Vitaly Kuznetsov wrote:
> > One minor remark: 'kvm_set_pte_rmapp()' handler is passed to
> > 'kvm_handle_gfn_range()' which does
> >
> > bool ret = false;
> >
> > for_each_slot_rmap_range(...)
> > ret |= handler(...);
> >
> > and I find '|=' to not be very natural with booleans. I'm not sure it's
> > worth changing though.
>
> Changing that would be "harder" than it seems because "ret = ret ||
> handler(...)" is wrong, and "|" is even more unnatural than "|=" (so
> much that clang warns about it).
>
> In fact I wonder if "|=" with a bool might end up warning with clang,
> which we should check before applying this patch. It doesn't seem to be
> in the original commit[1], but better safe than sorry: Nick, does clang
> intend to warn also about "ret |= fn()" and "ret &= fn()"? Technically,
> it is a bitwise operation with side-effects in the RHS.
I think that warning had more to due with typo's where `||` or `&&`
was meant (to short circuit the side effects) but `|` or `&` was typed
by accident, keeping both side effects. I'm not sure what the typo
would be in `ret |= fn();`.
>
> Paolo
>
> [1] https://github.com/llvm/llvm-project/commit/f59cc9542bfb461
>
--
Thanks,
~Nick Desaulniers
Powered by blists - more mailing lists