From e7c44b3f7c9924fa56b796a9281be4dfb27c9e23 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Tue, 6 Mar 2018 14:24:49 +0100 Subject: [PATCH] conf: Replace virDomainDiskSourceAuthParse by an XPath query Remove the rather bulky function in favor of an XPath query. Signed-off-by: Peter Krempa --- src/conf/domain_conf.c | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f872ddd868..91c9129f99 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8540,30 +8540,6 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node, } -static int -virDomainDiskSourceAuthParse(xmlNodePtr node, - virStorageAuthDefPtr *authdefsrc, - xmlXPathContextPtr ctxt) -{ - xmlNodePtr child; - virStorageAuthDefPtr authdef; - - for (child = node->children; child; child = child->next) { - if (child->type == XML_ELEMENT_NODE && - virXMLNodeNameEqual(child, "auth")) { - - if (!(authdef = virStorageAuthDefParse(child, ctxt))) - return -1; - - *authdefsrc = authdef; - return 0; - } - } - - return 0; -} - - static int virDomainDiskSourceEncryptionParse(xmlNodePtr node, virStorageEncryptionPtr *encryptionsrc) @@ -8627,6 +8603,7 @@ virDomainDiskSourceParse(xmlNodePtr node, { int ret = -1; xmlNodePtr saveNode = ctxt->node; + xmlNodePtr tmp; ctxt->node = node; @@ -8656,7 +8633,8 @@ virDomainDiskSourceParse(xmlNodePtr node, goto cleanup; } - if (virDomainDiskSourceAuthParse(node, &src->auth, ctxt) < 0) + if ((tmp = virXPathNode("./auth", ctxt)) && + !(src->auth = virStorageAuthDefParse(tmp, ctxt))) goto cleanup; if (virDomainDiskSourceEncryptionParse(node, &src->encryption) < 0) -- GitLab