KVM: VMX: replace "fall through" with "return true" to indicate different case
PATCH 1/1 KVM: VMX: replace "fall through" with "return true" to indicate different case
From: Miaohe Lin <[email protected]>
The second "/* fall through */" in rmode_exception() makes code harder to read. Replace it with "return true" to indicate they are different cases and also this improves the readability.
--- arch/x86/kvm/vmx/vmx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/vmx/vmx.c +1 -1
@@ -4495,7 +4495,7 @@ static bool rmode_exception(struct kvm_vcpu *vcpu, int vec)if (vcpu->guest_debug & (KVM_GUESTDBG_SINGLESTEP |KVM_GUESTDBG_USE_HW_BP ))return false; -/* fall through */ +return true;case DE_VECTOR :case OF_VECTOR :case BR_VECTOR :
Signature · 1 line
2.19.1
Quoted 3 lines · linmiaohe
The second "/* fall through */" in
rmode_exception()makes code harder to read. Replace it with "return true" to indicate they are different cases and also this improves the readability.
[]
arch/x86/kvm/vmx/vmx.c
Quoted 1 line
arch/x86/kvm/vmx/vmx.c +0
-0
[]
arch/x86/kvm/vmx/vmx.c static bool rmode_exception(struct kvm_vcpu *vcpu, int vec) · line 4498
Quoted 6 lines
arch/x86/kvm/vmx/vmx.c +1
-1@@ -4495,7 +4495,7 @@ static bool rmode_exception(struct kvm_vcpu *vcpu, int vec)if (vcpu->guest_debug & (KVM_GUESTDBG_SINGLESTEP |KVM_GUESTDBG_USE_HW_BP ))return false; -/* fall through */ +return true;
perhaps
return !(vcpu->guest_debug & (KVM_GUESTDBG_SINGLESTEP | KVM_GUESTDBG_USE_HW_BP));
Paolo Bonzini
maintainerQuoted 15 lines · Joe Perches
Quoted 3 lines · linmiaohe
The second "/* fall through */" in
rmode_exception()makes code harder to read. Replace it with "return true" to indicate they are different cases and also this improves the readability.[]
arch/x86/kvm/vmx/vmx.c
Quoted 1 line
arch/x86/kvm/vmx/vmx.c +0
-0[]
arch/x86/kvm/vmx/vmx.c static bool rmode_exception(struct kvm_vcpu *vcpu, int vec) · line 4498
Quoted 6 lines
arch/x86/kvm/vmx/vmx.c +1
-1@@ -4495,7 +4495,7 @@ static bool rmode_exception(struct kvm_vcpu *vcpu, int vec)if (vcpu->guest_debug & (KVM_GUESTDBG_SINGLESTEP |KVM_GUESTDBG_USE_HW_BP ))return false; -/* fall through */ +return true;perhaps
Quoted 1 line
return !(vcpu->guest_debug & (KVM_GUESTDBG_SINGLESTEP | KVM_GUESTDBG_USE_HW_BP));
Nice, thanks Joe.
Paolo
Quoted 17 lines · linmiaohe
From: Miaohe Lin <[email protected]>
The second "/* fall through */" in
rmode_exception()makes code harder to read. Replace it with "return true" to indicate they are different cases and also this improves the readability.Suggested-by Vitaly Kuznetsov <[email protected]>Signed-off-by Miaohe Lin <[email protected]>--- arch/x86/kvm/vmx/vmx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/x86/kvm/vmx/vmx.c +0
-0
arch/x86/kvm/vmx/vmx.c static bool rmode_exception(struct kvm_vcpu *vcpu, int vec) · line 4501
Quoted 8 lines
arch/x86/kvm/vmx/vmx.c +1
-1@@ -4495,7 +4495,7 @@ static bool rmode_exception(struct kvm_vcpu *vcpu, int vec)if (vcpu->guest_debug & (KVM_GUESTDBG_SINGLESTEP |KVM_GUESTDBG_USE_HW_BP ))return false; -/* fall through */ +return true;case DE_VECTOR :case OF_VECTOR :case BR_VECTOR :
Thanks!
Signature · 1 line
Vitaly
Quoted 17 lines · linmiaohe
From: Miaohe Lin <[email protected]>
The second "/* fall through */" in
rmode_exception()makes code harder to read. Replace it with "return true" to indicate they are different cases and also this improves the readability.Suggested-by Vitaly Kuznetsov <[email protected]>Signed-off-by Miaohe Lin <[email protected]>--- arch/x86/kvm/vmx/vmx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/x86/kvm/vmx/vmx.c +0
-0
arch/x86/kvm/vmx/vmx.c static bool rmode_exception(struct kvm_vcpu *vcpu, int vec) · line 4498
Quoted 5 lines
arch/x86/kvm/vmx/vmx.c +1
-1@@ -4495,7 +4495,7 @@ static bool rmode_exception(struct kvm_vcpu *vcpu, int vec)if (vcpu->guest_debug & (KVM_GUESTDBG_SINGLESTEP |KVM_GUESTDBG_USE_HW_BP ))return false; -/* fall through */ +return true;
I prefer the current code, i.e. the fall through. This code is already burdened with a fall through, from #BP->#DB, and IMO the fall through makes it more obvious that the vcpu->guest_debug checks are corner cases, while everything else is handled by common logic.
Quoted 6 lines
arch/x86/kvm/vmx/vmx.c +0
-0case DE_VECTOR :case OF_VECTOR :case BR_VECTOR :Signature · 1 line
2.19.1