[kvm-unit-tests PATCH 09/10] nVMX: Simplify test_vmxon() by returning directly on failure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Return '1' directly if a VMXON subtest fails, using a second variable and
a goto is silly.

Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>
---
 x86/vmx.c | 34 +++++++++++++---------------------
 1 file changed, 13 insertions(+), 21 deletions(-)

diff --git a/x86/vmx.c b/x86/vmx.c
index 09e54332..4562e91f 100644
--- a/x86/vmx.c
+++ b/x86/vmx.c
@@ -1455,43 +1455,35 @@ static int test_vmx_feature_control(void)
 
 static int test_vmxon(void)
 {
-	int ret, ret1;
 	u64 *vmxon_region;
 	int width = cpuid_maxphyaddr();
+	int ret;
 
 	/* Unaligned page access */
 	vmxon_region = (u64 *)((intptr_t)bsp_vmxon_region + 1);
-	ret1 = __vmxon_safe(vmxon_region);
-	report(ret1 < 0, "test vmxon with unaligned vmxon region");
-	if (ret1 >= 0) {
-		ret = 1;
-		goto out;
-	}
+	ret = __vmxon_safe(vmxon_region);
+	report(ret < 0, "test vmxon with unaligned vmxon region");
+	if (ret >= 0)
+		return 1;
 
 	/* gpa bits beyond physical address width are set*/
 	vmxon_region = (u64 *)((intptr_t)bsp_vmxon_region | ((u64)1 << (width+1)));
-	ret1 = __vmxon_safe(vmxon_region);
-	report(ret1 < 0, "test vmxon with bits set beyond physical address width");
-	if (ret1 >= 0) {
-		ret = 1;
-		goto out;
-	}
+	ret = __vmxon_safe(vmxon_region);
+	report(ret < 0, "test vmxon with bits set beyond physical address width");
+	if (ret >= 0)
+		return 1;
 
 	/* invalid revision identifier */
 	*bsp_vmxon_region = 0xba9da9;
-	ret1 = vmxon_safe();
-	report(ret1 < 0, "test vmxon with invalid revision identifier");
-	if (ret1 >= 0) {
-		ret = 1;
-		goto out;
-	}
+	ret = vmxon_safe();
+	report(ret < 0, "test vmxon with invalid revision identifier");
+	if (ret >= 0)
+		return 1;
 
 	/* and finally a valid region */
 	*bsp_vmxon_region = basic.revision;
 	ret = vmxon_safe();
 	report(!ret, "test vmxon with valid vmxon region");
-
-out:
 	return ret;
 }
 
-- 
2.36.1.255.ge46751e96f-goog




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux