On a Friday in 2020, Peter Krempa wrote:
Use XPath to get the host list instead of iterating through the
nodes.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/conf/domain_conf.c | 31 +++++++++++++++++--------------
1 file changed, 17 insertions(+), 14 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index acbc3f1c1e..ae7cb1e1c5 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -8234,23 +8234,26 @@ virDomainStorageNetworkParseHost(xmlNodePtr hostnode,
static int
virDomainStorageNetworkParseHosts(xmlNodePtr node,
+ xmlXPathContextPtr ctxt,
virStorageNetHostDefPtr *hosts,
size_t *nhosts)
{
- xmlNodePtr child;
+ g_autofree xmlNodePtr *hostnodes = NULL;
+ ssize_t nhostnodes;
+ size_t i;
+ VIR_XPATH_NODE_AUTORESTORE(ctxt);
Please drop the ending semicolon so that other declarations can be added
without triggering -Wdeclaration-after-statement.
It contains a pragma to suppress the -Wunused-variable warning (with
Clang, IIRC):
commit 8cc177fc5d2c1ac76b256bd8d104d894fa9845ec
util: xml: use pragma in VIR_XPATH_NODE_AUTORESTORE
And placing a semicolon after it creates an empty statement.
(This was the only way I found that VIR_XPATH_NODE_AUTORESTORE would not
be considered a statement and -Wdeclaration-after-statement could be
enabled with both GCC and Clang)
Reviewed-by: Ján Tomko <jtomko(a)redhat.com>
Jano