kvm: x86: vmx: return 'bool' type from vmcs12_read_any()
PATCH 1/1 kvm: x86: vmx: return 'bool' type from vmcs12_read_any()
Return value should be as bool type as this function declaration, static inline bool vmcs12_read_any().
--- arch/x86/kvm/vmx.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
arch/x86/kvm/vmx.c +6 -6
@@ -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. */ } }
Signature · 1 line
1.9.1
Paolo Bonzini
maintainerQuoted 2 lines · Tiejun Chen
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.
I've sent a patch that changes the return value to int.
Paolo
Quoted 42 lines
Signed-off-by Tiejun Chen <[email protected]>--- arch/x86/kvm/vmx.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)arch/x86/kvm/vmx.c +6
-6@@ -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. */ } }
Quoted 8 lines · Paolo Bonzini
Quoted 2 lines · Tiejun Chen
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.
Quoted 1 line
I've sent a patch that changes the return value to int.
Cool! I just have two minimal comments inline.
Thanks
Tiejun
Quoted 46 lines
Paolo
Quoted 42 lines
Signed-off-by Tiejun Chen <[email protected]>--- arch/x86/kvm/vmx.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)arch/x86/kvm/vmx.c +6
-6@@ -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. */ } }