[libvirt] [PATCH 13/34] conf: Simplify error paths in storage source component parsers

Peter Krempa pkrempa at redhat.com
Mon Mar 18 15:55:02 UTC 2019


virDomainDiskSourcePrivateDataParse and virDomainDiskSourcePRParse don't
need the 'cleanup' label any more thanks to VIR_XPATH_NODE_AUTORESTORE.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/conf/domain_conf.c | 27 ++++++++-------------------
 1 file changed, 8 insertions(+), 19 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index fb98629c77..0c650ffc2c 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -9028,7 +9028,6 @@ virDomainDiskSourcePrivateDataParse(xmlNodePtr node,
                                     virDomainXMLOptionPtr xmlopt)
 {
     VIR_XPATH_NODE_AUTORESTORE(ctxt);
-    int ret = -1;

     if (!(flags & VIR_DOMAIN_DEF_PARSE_STATUS) ||
         !xmlopt || !xmlopt->privateData.storageParse)
@@ -9036,18 +9035,13 @@ virDomainDiskSourcePrivateDataParse(xmlNodePtr node,

     ctxt->node = node;

-    if (!(ctxt->node = virXPathNode("./privateData", ctxt))) {
-        ret = 0;
-        goto cleanup;
-    }
+    if (!(ctxt->node = virXPathNode("./privateData", ctxt)))
+        return 0;

     if (xmlopt->privateData.storageParse(ctxt, src) < 0)
-        goto cleanup;
-
-    ret = 0;
+        return -1;

- cleanup:
-    return ret;
+    return 0;
 }


@@ -9057,21 +9051,16 @@ virDomainDiskSourcePRParse(xmlNodePtr node,
                            virStoragePRDefPtr *pr)
 {
     VIR_XPATH_NODE_AUTORESTORE(ctxt);
-    int ret = -1;

     ctxt->node = node;

-    if (!(ctxt->node = virXPathNode("./reservations", ctxt))) {
-        ret = 0;
-        goto cleanup;
-    }
+    if (!(ctxt->node = virXPathNode("./reservations", ctxt)))
+        return 0;

     if (!(*pr = virStoragePRDefParseXML(ctxt)))
-        goto cleanup;
+        return -1;

-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }


-- 
2.20.1




More information about the libvir-list mailing list