All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kvm: x86: vmx: return 'bool' type from vmcs12_read_any()
@ 2014-10-31  6:45 Tiejun Chen
  2014-11-04 17:34 ` Paolo Bonzini
  0 siblings, 1 reply; 3+ messages in thread
From: Tiejun Chen @ 2014-10-31  6:45 UTC (permalink / raw)
  To: pbonzini; +Cc: kvm

Return value should be as bool type as this function declaration,
static inline bool vmcs12_read_any().

Signed-off-by: Tiejun Chen <tiejun.chen@intel.com>
---
 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. */
 	}
 }
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] kvm: x86: vmx: return 'bool' type from vmcs12_read_any()
  2014-10-31  6:45 [PATCH] kvm: x86: vmx: return 'bool' type from vmcs12_read_any() Tiejun Chen
@ 2014-11-04 17:34 ` Paolo Bonzini
  2014-11-05  1:52   ` Chen, Tiejun
  0 siblings, 1 reply; 3+ messages in thread
From: Paolo Bonzini @ 2014-11-04 17:34 UTC (permalink / raw)
  To: Tiejun Chen; +Cc: kvm

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.

I've sent a patch that changes the return value to int.

Paolo

> Signed-off-by: Tiejun Chen <tiejun.chen@intel.com>
> ---
>  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. */
>  	}
>  }
>  
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] kvm: x86: vmx: return 'bool' type from vmcs12_read_any()
  2014-11-04 17:34 ` Paolo Bonzini
@ 2014-11-05  1:52   ` Chen, Tiejun
  0 siblings, 0 replies; 3+ messages in thread
From: Chen, Tiejun @ 2014-11-05  1:52 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: kvm

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 <tiejun.chen@intel.com>
>> ---
>>   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. */
>>   	}
>>   }
>>
>>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-11-05  1:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-31  6:45 [PATCH] kvm: x86: vmx: return 'bool' type from vmcs12_read_any() Tiejun Chen
2014-11-04 17:34 ` Paolo Bonzini
2014-11-05  1:52   ` Chen, Tiejun

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.