lkml.org 
[lkml]   [2021]   [Nov]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] KVM: Fix the warning by the min()
On Tue, Nov 16, 2021, Paolo Bonzini wrote:
> However, the second reason is that "r < 0" is a very common way to express
> "if there was an error". In this case that would be
>
> r = __kvm_io_bus_write(vcpu, bus, &range, val);
> if (r < 0) // "if __kvm_io_bus_write failed"
> return r;
>
> return 0;
>
> That "r < 0" is what will catch the attention of the person that is reading
> the code, no matter if it is an "if" or (as in the existing code), a
> "return". Using "min" removes the idiom that tells the person "this is
> checking for errors".

+1, there is zero chance that I would realize "min(r, 0)" is "handling" errors.

\
 
 \ /
  Last update: 2021-11-17 23:21    [W:0.058 / U:25.660 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site