lkml.org 
[lkml]   [2021]   [Nov]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] KVM: x86: fix cocci warnings
From
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.

Paolo

[1] https://github.com/llvm/llvm-project/commit/f59cc9542bfb461

\
 
 \ /
  Last update: 2021-11-16 10:52    [W:0.085 / U:0.480 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site