]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virDomainResctrlNew: Refactor allocation to remove 'cleanup' label
authorPeter Krempa <pkrempa@redhat.com>
Fri, 2 Oct 2020 08:36:59 +0000 (10:36 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 5 Oct 2020 13:50:45 +0000 (15:50 +0200)
If we use g_new0 there's no need for the 'cleanup' label as there's
nothing to fail after the allocation.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/conf/domain_conf.c

index f716338efdf3f7668c4806b75768aba6cf7ac781..175b632a388617d641a2d6a355cbbc3d9bf74374 100644 (file)
@@ -20900,7 +20900,6 @@ virDomainResctrlNew(xmlNodePtr node,
                     unsigned int flags)
 {
     virDomainResctrlDefPtr resctrl = NULL;
-    virDomainResctrlDefPtr ret = NULL;
     g_autofree char *vcpus_str = NULL;
     g_autofree char *alloc_id = NULL;
 
@@ -20923,18 +20922,13 @@ virDomainResctrlNew(xmlNodePtr node,
     }
 
     if (virResctrlAllocSetID(alloc, alloc_id) < 0)
-        goto cleanup;
-
-    if (VIR_ALLOC(resctrl) < 0)
-        goto cleanup;
+        return NULL;
 
+    resctrl = g_new0(virDomainResctrlDef, 1);
     resctrl->vcpus = virBitmapNewCopy(vcpus);
     resctrl->alloc = virObjectRef(alloc);
 
-    ret = g_steal_pointer(&resctrl);
- cleanup:
-    virDomainResctrlDefFree(resctrl);
-    return ret;
+    return resctrl;
 }