[PATCH 02/17] virDomainStorageNetworkParseHosts: Switch to a more modern XML parsing approach

Ján Tomko jtomko at redhat.com
Fri Sep 11 16:51:16 UTC 2020


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 at 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 at redhat.com>

Jano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20200911/4cc5f0f8/attachment-0001.sig>


More information about the libvir-list mailing list