[libvirt] [PATCH 04/21] conf: ns.parse: decouple call from condition

Ján Tomko jtomko at redhat.com
Tue Aug 20 23:15:26 UTC 2019


In the future we will perform more actions if ns.parse
is present. Decouple the condition from the actual call.

Signed-off-by: Ján Tomko <jtomko at redhat.com>
---
 src/conf/domain_conf.c  | 7 ++++---
 src/conf/network_conf.c | 7 ++++---
 src/conf/storage_conf.c | 7 ++++---
 3 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index f848483235..c8c304d2a2 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -21343,9 +21343,10 @@ virDomainDefParseXML(xmlDocPtr xml,
      */
     def->ns = xmlopt->ns;
 
-    if (def->ns.parse &&
-        (def->ns.parse)(ctxt, &def->namespaceData) < 0)
-        goto error;
+    if (def->ns.parse) {
+        if ((def->ns.parse)(ctxt, &def->namespaceData) < 0)
+            goto error;
+    }
 
     return def;
 
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index c5a243684a..f55b9e5409 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -2050,9 +2050,10 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt,
 
     if (xmlopt)
         def->ns = xmlopt->ns;
-    if (def->ns.parse &&
-        (def->ns.parse)(ctxt, &def->namespaceData) < 0)
-        goto error;
+    if (def->ns.parse) {
+        if ((def->ns.parse)(ctxt, &def->namespaceData) < 0)
+            goto error;
+    }
 
     ctxt->node = save;
     return def;
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index 05055cdc29..a2b977989f 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -997,9 +997,10 @@ virStoragePoolDefParseXML(xmlXPathContextPtr ctxt)
     /* Make a copy of all the callback pointers here for easier use,
      * especially during the virStoragePoolSourceClear method */
     def->ns = options->ns;
-    if (def->ns.parse &&
-        (def->ns.parse)(ctxt, &def->namespaceData) < 0)
-        return NULL;
+    if (def->ns.parse) {
+        if ((def->ns.parse)(ctxt, &def->namespaceData) < 0)
+            return NULL;
+    }
 
     VIR_STEAL_PTR(ret, def);
     return ret;
-- 
2.19.2




More information about the libvir-list mailing list