render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
a41c76
From 45226d208c57719b50152dbec99a75969989208b Mon Sep 17 00:00:00 2001
a41c76
Message-Id: <45226d208c57719b50152dbec99a75969989208b@dist-git>
a41c76
From: Jiri Denemark <jdenemar@redhat.com>
a41c76
Date: Tue, 26 May 2020 10:59:12 +0200
a41c76
Subject: [PATCH] cpu_x86: Use g_auto* in virCPUx86DataParse
a41c76
MIME-Version: 1.0
a41c76
Content-Type: text/plain; charset=UTF-8
a41c76
Content-Transfer-Encoding: 8bit
a41c76
a41c76
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
a41c76
Reviewed-by: Ján Tomko <jtomko@redhat.com>
a41c76
(cherry picked from commit c1532711dda6db27c7f6fa7d86ab5ec5d2ab2224)
a41c76
a41c76
https://bugzilla.redhat.com/show_bug.cgi?id=1840010
a41c76
a41c76
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
a41c76
Message-Id: <e98c6869043aa0b7d0cc3adffe879f5d7d3c39f2.1590483392.git.jdenemar@redhat.com>
a41c76
Reviewed-by: Ján Tomko <jtomko@redhat.com>
a41c76
---
a41c76
 src/cpu/cpu_x86.c | 23 ++++++++---------------
a41c76
 1 file changed, 8 insertions(+), 15 deletions(-)
a41c76
a41c76
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
a41c76
index cb5a2f941e..107fd9227d 100644
a41c76
--- a/src/cpu/cpu_x86.c
a41c76
+++ b/src/cpu/cpu_x86.c
a41c76
@@ -1636,8 +1636,8 @@ virCPUx86DataFormat(const virCPUData *data)
a41c76
 static virCPUDataPtr
a41c76
 virCPUx86DataParse(xmlXPathContextPtr ctxt)
a41c76
 {
a41c76
-    xmlNodePtr *nodes = NULL;
a41c76
-    virCPUDataPtr cpuData = NULL;
a41c76
+    g_autofree xmlNodePtr *nodes = NULL;
a41c76
+    g_autoptr(virCPUData) cpuData = NULL;
a41c76
     virCPUx86DataItem item;
a41c76
     size_t i;
a41c76
     int n;
a41c76
@@ -1646,11 +1646,11 @@ virCPUx86DataParse(xmlXPathContextPtr ctxt)
a41c76
     if (n <= 0) {
a41c76
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
a41c76
                        _("no x86 CPU data found"));
a41c76
-        goto error;
a41c76
+        return NULL;
a41c76
     }
a41c76
 
a41c76
     if (!(cpuData = virCPUDataNew(VIR_ARCH_X86_64)))
a41c76
-        goto error;
a41c76
+        return NULL;
a41c76
 
a41c76
     for (i = 0; i < n; i++) {
a41c76
         ctxt->node = nodes[i];
a41c76
@@ -1658,28 +1658,21 @@ virCPUx86DataParse(xmlXPathContextPtr ctxt)
a41c76
             if (x86ParseCPUID(ctxt, &item) < 0) {
a41c76
                 virReportError(VIR_ERR_INTERNAL_ERROR,
a41c76
                                _("failed to parse cpuid[%zu]"), i);
a41c76
-                goto error;
a41c76
+                return NULL;
a41c76
             }
a41c76
         } else {
a41c76
             if (x86ParseMSR(ctxt, &item) < 0) {
a41c76
                 virReportError(VIR_ERR_INTERNAL_ERROR,
a41c76
                                _("failed to parse msr[%zu]"), i);
a41c76
-                goto error;
a41c76
+                return NULL;
a41c76
             }
a41c76
         }
a41c76
 
a41c76
         if (virCPUx86DataAdd(cpuData, &item) < 0)
a41c76
-            goto error;
a41c76
+            return NULL;
a41c76
     }
a41c76
 
a41c76
- cleanup:
a41c76
-    VIR_FREE(nodes);
a41c76
-    return cpuData;
a41c76
-
a41c76
- error:
a41c76
-    virCPUx86DataFree(cpuData);
a41c76
-    cpuData = NULL;
a41c76
-    goto cleanup;
a41c76
+    return g_steal_pointer(&cpuData);
a41c76
 }
a41c76
 
a41c76
 
a41c76
-- 
a41c76
2.26.2
a41c76