All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] KVM: remove redundant code in kvm_arch_vm_ioctl
@ 2019-10-21  8:52 Miaohe Lin
  2019-10-21  8:59 ` Paolo Bonzini
  0 siblings, 1 reply; 2+ messages in thread
From: Miaohe Lin @ 2019-10-21  8:52 UTC (permalink / raw)
  To: pbonzini, rkrcmar, sean.j.christopherson, vkuznets, wanpengli,
	jmattson, joro, tglx, mingo, bp, hpa
  Cc: x86, kvm, linux-kernel, linmiaohe

If we reach here with r = 0, we will reassign r = 0
unnecesarry, then do the label set_irqchip_out work.
If we reach here with r != 0, then we will do the label
work directly. So this if statement and r = 0 assignment
is redundant. We remove them and therefore we can get rid
of odd set_irqchip_out lable further pointed out by tglx.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 arch/x86/kvm/x86.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 661e2bf38526..cd4ca8c2f7de 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -4913,13 +4913,8 @@ long kvm_arch_vm_ioctl(struct file *filp,
 		}
 
 		r = -ENXIO;
-		if (!irqchip_kernel(kvm))
-			goto set_irqchip_out;
-		r = kvm_vm_ioctl_set_irqchip(kvm, chip);
-		if (r)
-			goto set_irqchip_out;
-		r = 0;
-	set_irqchip_out:
+		if (irqchip_kernel(kvm))
+			r = kvm_vm_ioctl_set_irqchip(kvm, chip);
 		kfree(chip);
 		break;
 	}
-- 
2.19.1


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

* Re: [PATCH v2] KVM: remove redundant code in kvm_arch_vm_ioctl
  2019-10-21  8:52 [PATCH v2] KVM: remove redundant code in kvm_arch_vm_ioctl Miaohe Lin
@ 2019-10-21  8:59 ` Paolo Bonzini
  0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2019-10-21  8:59 UTC (permalink / raw)
  To: Miaohe Lin, rkrcmar, sean.j.christopherson, vkuznets, wanpengli,
	jmattson, joro, tglx, mingo, bp, hpa
  Cc: x86, kvm, linux-kernel

On 21/10/19 10:52, Miaohe Lin wrote:
> If we reach here with r = 0, we will reassign r = 0
> unnecesarry, then do the label set_irqchip_out work.
> If we reach here with r != 0, then we will do the label
> work directly. So this if statement and r = 0 assignment
> is redundant. We remove them and therefore we can get rid
> of odd set_irqchip_out lable further pointed out by tglx.

While Thomas's suggestion certainly makes sense, I prefer to keep the
get and set cases similar to each other, so I queued your v1 patch.
Thanks for making the KVM code cleaner!

Paolo

> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> ---
>  arch/x86/kvm/x86.c | 9 ++-------
>  1 file changed, 2 insertions(+), 7 deletions(-)
> 
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 661e2bf38526..cd4ca8c2f7de 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -4913,13 +4913,8 @@ long kvm_arch_vm_ioctl(struct file *filp,
>  		}
>  
>  		r = -ENXIO;
> -		if (!irqchip_kernel(kvm))
> -			goto set_irqchip_out;
> -		r = kvm_vm_ioctl_set_irqchip(kvm, chip);
> -		if (r)
> -			goto set_irqchip_out;
> -		r = 0;
> -	set_irqchip_out:
> +		if (irqchip_kernel(kvm))
> +			r = kvm_vm_ioctl_set_irqchip(kvm, chip);
>  		kfree(chip);
>  		break;
>  	}
> 


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

end of thread, other threads:[~2019-10-21  8:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-21  8:52 [PATCH v2] KVM: remove redundant code in kvm_arch_vm_ioctl Miaohe Lin
2019-10-21  8:59 ` Paolo Bonzini

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.