]> xenbits.xensource.com Git - libvirt.git/commitdiff
cpu_x86: Use g_auto* in x86FeatureParse
authorJiri Denemark <jdenemar@redhat.com>
Wed, 25 Mar 2020 09:45:40 +0000 (10:45 +0100)
committerJiri Denemark <jdenemar@redhat.com>
Wed, 8 Apr 2020 15:41:00 +0000 (17:41 +0200)
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/cpu/cpu_x86.c

index 94a5551000e920f68a4be29ebe34215042387a6c..248c774777bdb6e5695360f454cd316c4ef7af15 100644 (file)
@@ -1023,13 +1023,12 @@ x86FeatureParse(xmlXPathContextPtr ctxt,
                 void *data)
 {
     virCPUx86MapPtr map = data;
-    xmlNodePtr *nodes = NULL;
-    virCPUx86FeaturePtr feature;
+    g_autofree xmlNodePtr *nodes = NULL;
+    g_autoptr(virCPUx86Feature) feature = NULL;
     virCPUx86DataItem item;
     size_t i;
     int n;
-    char *str = NULL;
-    int ret = -1;
+    g_autofree char *str = NULL;
 
     feature = g_new0(virCPUx86Feature, 1);
     feature->migratable = true;
@@ -1038,7 +1037,7 @@ x86FeatureParse(xmlXPathContextPtr ctxt,
     if (x86FeatureFind(map, feature->name)) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("CPU feature %s already defined"), feature->name);
-        goto cleanup;
+        return -1;
     }
 
     str = virXPathString("string(@migratable)", ctxt);
@@ -1047,13 +1046,13 @@ x86FeatureParse(xmlXPathContextPtr ctxt,
 
     n = virXPathNodeSet("./cpuid|./msr", ctxt, &nodes);
     if (n < 0)
-        goto cleanup;
+        return -1;
 
     if (n == 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("Missing cpuid or msr element in feature %s"),
                        feature->name);
-        goto cleanup;
+        return -1;
     }
 
     for (i = 0; i < n; i++) {
@@ -1063,37 +1062,31 @@ x86FeatureParse(xmlXPathContextPtr ctxt,
                 virReportError(VIR_ERR_INTERNAL_ERROR,
                                _("Invalid cpuid[%zu] in %s feature"),
                                i, feature->name);
-                goto cleanup;
+                return -1;
             }
         } else {
             if (x86ParseMSR(ctxt, &item) < 0) {
                 virReportError(VIR_ERR_INTERNAL_ERROR,
                                _("Invalid msr[%zu] in %s feature"),
                                i, feature->name);
-                goto cleanup;
+                return -1;
             }
         }
 
         if (virCPUx86DataAddItem(&feature->data, &item))
-            goto cleanup;
+            return -1;
     }
 
     if (!feature->migratable &&
         VIR_APPEND_ELEMENT_COPY(map->migrate_blockers,
                                 map->nblockers,
                                 feature) < 0)
-        goto cleanup;
+        return -1;
 
     if (VIR_APPEND_ELEMENT(map->features, map->nfeatures, feature) < 0)
-        goto cleanup;
-
-    ret = 0;
+        return -1;
 
- cleanup:
-    x86FeatureFree(feature);
-    VIR_FREE(nodes);
-    VIR_FREE(str);
-    return ret;
+    return 0;
 }