From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Chen, Tiejun" Subject: Re: [PATCH] kvm: x86: vmx: return 'bool' type from vmcs12_read_any() Date: Wed, 05 Nov 2014 09:52:40 +0800 Message-ID: <545982E8.3070707@intel.com> References: <1414737940-4106-1-git-send-email-tiejun.chen@intel.com> <54590E1B.1000805@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org To: Paolo Bonzini Return-path: Received: from mga03.intel.com ([134.134.136.65]:53156 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751435AbaKEBwn (ORCPT ); Tue, 4 Nov 2014 20:52:43 -0500 In-Reply-To: <54590E1B.1000805@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On 2014/11/5 1:34, Paolo Bonzini wrote: > On 31/10/2014 07:45, Tiejun Chen wrote: >> Return value should be as bool type as this function declaration, >> static inline bool vmcs12_read_any(). > > Actually, bool return values are in general a bad idea if you mean > success/fail, especially if you can use POSIX error codes such as in > this case ENOENT. > Yeah. > I've sent a patch that changes the return value to int. Cool! I just have two minimal comments inline. Thanks Tiejun > > Paolo > >> Signed-off-by: Tiejun Chen >> --- >> arch/x86/kvm/vmx.c | 12 ++++++------ >> 1 file changed, 6 insertions(+), 6 deletions(-) >> >> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c >> index 9fa1f46..9d44d6e 100644 >> --- a/arch/x86/kvm/vmx.c >> +++ b/arch/x86/kvm/vmx.c >> @@ -6499,25 +6499,25 @@ static inline bool vmcs12_read_any(struct kvm_vcpu *vcpu, >> char *p; >> >> if (offset < 0) >> - return 0; >> + return false; >> >> p = ((char *)(get_vmcs12(vcpu))) + offset; >> >> switch (vmcs_field_type(field)) { >> case VMCS_FIELD_TYPE_NATURAL_WIDTH: >> *ret = *((natural_width *)p); >> - return 1; >> + return true; >> case VMCS_FIELD_TYPE_U16: >> *ret = *((u16 *)p); >> - return 1; >> + return true; >> case VMCS_FIELD_TYPE_U32: >> *ret = *((u32 *)p); >> - return 1; >> + return true; >> case VMCS_FIELD_TYPE_U64: >> *ret = *((u64 *)p); >> - return 1; >> + return true; >> default: >> - return 0; /* can never happen. */ >> + return false; /* can never happen. */ >> } >> } >> >> >