[PATCH 7/9] conf: domain: Refactor cleanup in virDomainDefParseNode

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use VIR_AUTOPTR for temporary locals and get rid of the cleanup label.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/conf/domain_conf.c | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 5fec2e5220..35573c0aaf 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -21558,32 +21558,26 @@ virDomainDefParseNode(xmlDocPtr xml,
                       void *parseOpaque,
                       unsigned int flags)
 {
-    xmlXPathContextPtr ctxt = NULL;
-    virDomainDefPtr def = NULL;
-    virDomainDefPtr ret = NULL;
+    VIR_AUTOPTR(xmlXPathContext) ctxt = NULL;
+    VIR_AUTOPTR(virDomainDef) def = NULL;

     if (!(ctxt = virXMLXPathContextNew(xml)))
-        goto cleanup;
+        return NULL;

     ctxt->node = root;

     if (!(def = virDomainDefParseXML(xml, ctxt, caps, xmlopt, flags)))
-        goto cleanup;
+        return NULL;

     /* callback to fill driver specific domain aspects */
     if (virDomainDefPostParse(def, caps, flags, xmlopt, parseOpaque) < 0)
-        goto cleanup;
+        return NULL;

     /* validate configuration */
     if (virDomainDefValidate(def, caps, flags, xmlopt) < 0)
-        goto cleanup;
-
-    VIR_STEAL_PTR(ret, def);
+        return NULL;

- cleanup:
-    virDomainDefFree(def);
-    xmlXPathFreeContext(ctxt);
-    return ret;
+    VIR_RETURN_PTR(def);
 }


-- 
2.21.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux