]> xenbits.xensource.com Git - libvirt.git/commitdiff
virDomainSchedulerParse: Refactor cleanup
authorPeter Krempa <pkrempa@redhat.com>
Tue, 7 Dec 2021 16:16:14 +0000 (17:16 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 10 Dec 2021 15:36:24 +0000 (16:36 +0100)
Automatically free the 'ret' temporary bitmap and get rid of the cleanup
section.

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

index 107d2a4f5d7ab137c536ce4c3c0cbbbfc88f6282..c634e7dd4191c920e0fb0854eb93a4c9ac901d2b 100644 (file)
@@ -17977,34 +17977,30 @@ virDomainSchedulerParse(xmlNodePtr node,
                         virProcessSchedPolicy *policy,
                         int *priority)
 {
-    virBitmap *ret = NULL;
+    g_autoptr(virBitmap) ret = NULL;
     g_autofree char *tmp = NULL;
 
     if (!(tmp = virXMLPropString(node, attributeName))) {
         virReportError(VIR_ERR_XML_ERROR,
                        _("Missing attribute '%s' in element '%s'"),
                        attributeName, elementName);
-        goto error;
+        return NULL;
     }
 
     if (virBitmapParse(tmp, &ret, VIR_DOMAIN_CPUMASK_LEN) < 0)
-        goto error;
+        return NULL;
 
     if (virBitmapIsAllClear(ret)) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                        _("'%s' scheduler bitmap '%s' is empty"),
                        attributeName, tmp);
-        goto error;
+        return NULL;
     }
 
     if (virDomainSchedulerParseCommonAttrs(node, policy, priority) < 0)
-        goto error;
-
-    return ret;
+        return NULL;
 
- error:
-    virBitmapFree(ret);
-    return NULL;
+    return g_steal_pointer(&ret);
 }