render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
a41c76
From 39dea7f80de53e9f7fb8f298d1f9f7f32f20fc29 Mon Sep 17 00:00:00 2001
a41c76
Message-Id: <39dea7f80de53e9f7fb8f298d1f9f7f32f20fc29@dist-git>
a41c76
From: Jiri Denemark <jdenemar@redhat.com>
a41c76
Date: Tue, 26 May 2020 10:59:08 +0200
a41c76
Subject: [PATCH] cpu_x86: Use g_auto* in x86FeatureParse
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 3125688f78f6289e51bfdaa196addb230b0de4e1)
a41c76
a41c76
https://bugzilla.redhat.com/show_bug.cgi?id=1840010
a41c76
a41c76
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
a41c76
Message-Id: <14cf6ca6816ee8bda3e195aa5218162b280715b5.1590483392.git.jdenemar@redhat.com>
a41c76
Reviewed-by: Ján Tomko <jtomko@redhat.com>
a41c76
---
a41c76
 src/cpu/cpu_x86.c | 31 ++++++++++++-------------------
a41c76
 1 file changed, 12 insertions(+), 19 deletions(-)
a41c76
a41c76
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
a41c76
index 3ffddf0342..10c5fbacf7 100644
a41c76
--- a/src/cpu/cpu_x86.c
a41c76
+++ b/src/cpu/cpu_x86.c
a41c76
@@ -1023,13 +1023,12 @@ x86FeatureParse(xmlXPathContextPtr ctxt,
a41c76
                 void *data)
a41c76
 {
a41c76
     virCPUx86MapPtr map = data;
a41c76
-    xmlNodePtr *nodes = NULL;
a41c76
-    virCPUx86FeaturePtr feature;
a41c76
+    g_autofree xmlNodePtr *nodes = NULL;
a41c76
+    g_autoptr(virCPUx86Feature) feature = NULL;
a41c76
     virCPUx86DataItem item;
a41c76
     size_t i;
a41c76
     int n;
a41c76
-    char *str = NULL;
a41c76
-    int ret = -1;
a41c76
+    g_autofree char *str = NULL;
a41c76
 
a41c76
     feature = g_new0(virCPUx86Feature, 1);
a41c76
     feature->migratable = true;
a41c76
@@ -1038,7 +1037,7 @@ x86FeatureParse(xmlXPathContextPtr ctxt,
a41c76
     if (x86FeatureFind(map, feature->name)) {
a41c76
         virReportError(VIR_ERR_INTERNAL_ERROR,
a41c76
                        _("CPU feature %s already defined"), feature->name);
a41c76
-        goto cleanup;
a41c76
+        return -1;
a41c76
     }
a41c76
 
a41c76
     str = virXPathString("string(@migratable)", ctxt);
a41c76
@@ -1047,13 +1046,13 @@ x86FeatureParse(xmlXPathContextPtr ctxt,
a41c76
 
a41c76
     n = virXPathNodeSet("./cpuid|./msr", ctxt, &nodes);
a41c76
     if (n < 0)
a41c76
-        goto cleanup;
a41c76
+        return -1;
a41c76
 
a41c76
     if (n == 0) {
a41c76
         virReportError(VIR_ERR_INTERNAL_ERROR,
a41c76
                        _("Missing cpuid or msr element in feature %s"),
a41c76
                        feature->name);
a41c76
-        goto cleanup;
a41c76
+        return -1;
a41c76
     }
a41c76
 
a41c76
     for (i = 0; i < n; i++) {
a41c76
@@ -1063,37 +1062,31 @@ x86FeatureParse(xmlXPathContextPtr ctxt,
a41c76
                 virReportError(VIR_ERR_INTERNAL_ERROR,
a41c76
                                _("Invalid cpuid[%zu] in %s feature"),
a41c76
                                i, feature->name);
a41c76
-                goto cleanup;
a41c76
+                return -1;
a41c76
             }
a41c76
         } else {
a41c76
             if (x86ParseMSR(ctxt, &item) < 0) {
a41c76
                 virReportError(VIR_ERR_INTERNAL_ERROR,
a41c76
                                _("Invalid msr[%zu] in %s feature"),
a41c76
                                i, feature->name);
a41c76
-                goto cleanup;
a41c76
+                return -1;
a41c76
             }
a41c76
         }
a41c76
 
a41c76
         if (virCPUx86DataAddItem(&feature->data, &item))
a41c76
-            goto cleanup;
a41c76
+            return -1;
a41c76
     }
a41c76
 
a41c76
     if (!feature->migratable &&
a41c76
         VIR_APPEND_ELEMENT_COPY(map->migrate_blockers,
a41c76
                                 map->nblockers,
a41c76
                                 feature) < 0)
a41c76
-        goto cleanup;
a41c76
+        return -1;
a41c76
 
a41c76
     if (VIR_APPEND_ELEMENT(map->features, map->nfeatures, feature) < 0)
a41c76
-        goto cleanup;
a41c76
-
a41c76
-    ret = 0;
a41c76
+        return -1;
a41c76
 
a41c76
- cleanup:
a41c76
-    x86FeatureFree(feature);
a41c76
-    VIR_FREE(nodes);
a41c76
-    VIR_FREE(str);
a41c76
-    return ret;
a41c76
+    return 0;
a41c76
 }
a41c76
 
a41c76
 
a41c76
-- 
a41c76
2.26.2
a41c76