render / rpms / libvirt

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