Messages in this thread | | | Date | Wed, 17 Nov 2021 22:19:34 +0000 | From | Sean Christopherson <> | Subject | Re: [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.
| |