Use two separate variables for the nodes and count instead. Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- src/conf/domain_conf.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 5c91cbd0db..797914b7bc 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6216,31 +6216,32 @@ virDomainNetIPInfoParseXML(const char *source, xmlXPathContextPtr ctxt, virNetDevIPInfo *def) { - int nnodes; int ret = -1; size_t i; - g_autofree xmlNodePtr *nodes = NULL; + g_autofree xmlNodePtr *ipNodes = NULL; + int nipNodes; + g_autofree xmlNodePtr *routeNodes = NULL; + int nrouteNodes; - if ((nnodes = virXPathNodeSet("./ip", ctxt, &nodes)) < 0) + if ((nipNodes = virXPathNodeSet("./ip", ctxt, &ipNodes)) < 0) goto cleanup; - for (i = 0; i < nnodes; i++) { + for (i = 0; i < nipNodes; i++) { virNetDevIPAddr *ip = NULL; - if (!(ip = virDomainNetIPParseXML(nodes[i]))) + if (!(ip = virDomainNetIPParseXML(ipNodes[i]))) goto cleanup; VIR_APPEND_ELEMENT(def->ips, def->nips, ip); } - VIR_FREE(nodes); - if ((nnodes = virXPathNodeSet("./route", ctxt, &nodes)) < 0) + if ((nrouteNodes = virXPathNodeSet("./route", ctxt, &routeNodes)) < 0) goto cleanup; - for (i = 0; i < nnodes; i++) { + for (i = 0; i < nrouteNodes; i++) { virNetDevIPRoute *route = NULL; - if (!(route = virNetDevIPRouteParseXML(source, nodes[i], ctxt))) + if (!(route = virNetDevIPRouteParseXML(source, routeNodes[i], ctxt))) goto cleanup; VIR_APPEND_ELEMENT(def->routes, def->nroutes, route); -- 2.37.1