Skip to contentSkip to conversation

KVM: remove redundant code in kvm_arch_vm_ioctl

PATCH In review Miaohe Lin 2 participants 2 messages Oct 21, 2019

Subsystems (3)
lore
Share & tools
lore

Miaohe Lin

author
#0 lore raw

PATCH v2 1/1 KVM: remove redundant code in kvm_arch_vm_ioctl

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.

---
 arch/x86/kvm/x86.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
arch/x86/kvm/x86.c +2 -7
index 661e2bf38526..cd4ca8c2f7de 100644
@@ -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;
 	}
Signature · 1 line
2.19.1
maintainer
#1 lore raw
Quoted 6 lines · Miaohe Lin

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

Quoted 26 lines
---
 arch/x86/kvm/x86.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
arch/x86/kvm/x86.c +2 -7
index 661e2bf38526..cd4ca8c2f7de 100644
@@ -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;
 	}