[libvirt PATCH 7/8] bhyve: bhyveConnectCompareCPU: remove cleanup label

Ján Tomko jtomko at redhat.com
Fri Dec 10 16:06:17 UTC 2021


Return the desired values directly and clean up the redundant
else branches.

Signed-off-by: Ján Tomko <jtomko at redhat.com>
---
 src/bhyve/bhyve_driver.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
index e445c8cadf..cb1544665e 100644
--- a/src/bhyve/bhyve_driver.c
+++ b/src/bhyve/bhyve_driver.c
@@ -1431,7 +1431,6 @@ bhyveConnectCompareCPU(virConnectPtr conn,
                        unsigned int flags)
 {
     struct _bhyveConn *driver = conn->privateData;
-    int ret = VIR_CPU_COMPARE_ERROR;
     g_autoptr(virCaps) caps = NULL;
     bool failIncompatible;
     bool validateXML;
@@ -1441,30 +1440,27 @@ bhyveConnectCompareCPU(virConnectPtr conn,
                   VIR_CPU_COMPARE_ERROR);
 
     if (virConnectCompareCPUEnsureACL(conn) < 0)
-        goto cleanup;
+        return VIR_CPU_COMPARE_ERROR;
 
     failIncompatible = !!(flags & VIR_CONNECT_COMPARE_CPU_FAIL_INCOMPATIBLE);
     validateXML = !!(flags & VIR_CONNECT_COMPARE_CPU_VALIDATE_XML);
 
     if (!(caps = bhyveDriverGetCapabilities(driver)))
-        goto cleanup;
+        return VIR_CPU_COMPARE_ERROR;
 
     if (!caps->host.cpu ||
         !caps->host.cpu->model) {
         if (failIncompatible) {
             virReportError(VIR_ERR_CPU_INCOMPATIBLE, "%s",
                            _("cannot get host CPU capabilities"));
-        } else {
-            VIR_WARN("cannot get host CPU capabilities");
-            ret = VIR_CPU_COMPARE_INCOMPATIBLE;
+            return VIR_CPU_COMPARE_ERROR;
         }
-    } else {
-        ret = virCPUCompareXML(caps->host.arch, caps->host.cpu,
-                               xmlDesc, failIncompatible, validateXML);
+        VIR_WARN("cannot get host CPU capabilities");
+        return VIR_CPU_COMPARE_INCOMPATIBLE;
     }
 
- cleanup:
-    return ret;
+    return virCPUCompareXML(caps->host.arch, caps->host.cpu,
+                            xmlDesc, failIncompatible, validateXML);
 }
 
 static int
-- 
2.31.1




More information about the libvir-list mailing list