Re: [PATCH] KVM: Fix the warning by the min()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux