]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
cpu_map: Use g_auto* in loadData
authorTim Wiederhake <twiederh@redhat.com>
Wed, 9 Sep 2020 06:37:50 +0000 (08:37 +0200)
committerJán Tomko <jtomko@redhat.com>
Wed, 9 Sep 2020 06:44:22 +0000 (08:44 +0200)
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
src/cpu/cpu_map.c

index 3abec68c60422abdddb5bf959c103f2796c600ed..65d244e0118a8be63b6c4ad5ccf74a9c1d438b49 100644 (file)
@@ -39,20 +39,19 @@ loadData(const char *mapfile,
          cpuMapLoadCallback callback,
          void *data)
 {
-    int ret = -1;
     VIR_XPATH_NODE_AUTORESTORE(ctxt)
-    xmlNodePtr *nodes = NULL;
+    g_autofree xmlNodePtr *nodes = NULL;
     int n;
     size_t i;
     int rv;
 
     if ((n = virXPathNodeSet(element, ctxt, &nodes)) < 0)
-        goto cleanup;
+        return -1;
 
     if (n > 0 && !callback) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("Unexpected element '%s' in CPU map '%s'"), element, mapfile);
-        goto cleanup;
+        return -1;
     }
 
     for (i = 0; i < n; i++) {
@@ -60,22 +59,17 @@ loadData(const char *mapfile,
         if (!name) {
             virReportError(VIR_ERR_INTERNAL_ERROR,
                            _("cannot find %s name in CPU map '%s'"), element, mapfile);
-            goto cleanup;
+            return -1;
         }
         VIR_DEBUG("Load %s name %s", element, name);
         ctxt->node = nodes[i];
         rv = callback(ctxt, name, data);
         VIR_FREE(name);
         if (rv < 0)
-            goto cleanup;
+            return -1;
     }
 
-    ret = 0;
-
- cleanup:
-    VIR_FREE(nodes);
-
-    return ret;
+    return 0;
 }
 
 static int