Skip to contentSkip to conversation

KVM: remove redundant code in kvm_arch_vm_ioctl

PATCH Superseded Miaohe Lin 3 participants 3 messages Oct 21, 2019

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Miaohe Lin

author
#0 lore raw

PATCH 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.

---
 arch/x86/kvm/x86.c | 3 ---
 1 file changed, 3 deletions(-)
arch/x86/kvm/x86.c +0 -3
index 661e2bf38526..0b3ebc2afb3d 100644
@@ -4916,9 +4916,6 @@ long kvm_arch_vm_ioctl(struct file *filp,
 		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:
 		kfree(chip);
 		break;
Signature · 1 line
2.19.1
#1 lore raw
Quoted 16 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.

---
 arch/x86/kvm/x86.c | 3 ---
 1 file changed, 3 deletions(-)
arch/x86/kvm/x86.c +0 -0
index 661e2bf38526..0b3ebc2afb3d 100644

arch/x86/kvm/x86.c long kvm_arch_vm_ioctl(struct file *filp, · line 4921

Quoted 9 lines
arch/x86/kvm/x86.c +0 -3
@@ -4916,9 +4916,6 @@ long kvm_arch_vm_ioctl(struct file *filp,
 		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:
 		kfree(chip);
 		break;

Can you please get rid of that odd jump label completely?

if (irqchip_kernel(kvm))

			r = kvm_vm_ioctl_set_irqchip(kvm, chip);

Hmm?

Thanks,

tglx

maintainer
#2 lore raw
Quoted 4 lines · Thomas Gleixner

Can you please get rid of that odd jump label completely?

if (irqchip_kernel(kvm))

			r = kvm_vm_ioctl_set_irqchip(kvm, chip);

Keeping the label has the advantage of making the get and set cases a bit more similar (the get case has to do a copy_to_user after kvm_vm_ioctl_get_irqchip returns). Unfortunately struct kvm_irqchip is quite big (520 bytes) so we don't allocate it on the stack.

So I queued Miaohe's patch.

Paolo