lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Wed, 17 Nov 2021 22:19:34 +0000
From:   Sean Christopherson <seanjc@...gle.com>
To:     Paolo Bonzini <pbonzini@...hat.com>
Cc:     zhaoxiao <zhaoxiao@...ontech.com>, kvm@...r.kernel.org,
        linux-kernel@...r.kernel.org
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.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ