Clean up the style a bit w/r/t to not using a unary operator on an integer value that could be zero - compare vs. zero instead. Set the def->mem_nodes[*].distances to rdist or ldist inside the if condition - no need to set outside since the value being set to is what was fetched. During cleanup, be sure to initialize the ndistances on error and use the < 0 comparison not the unary one. Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx> --- src/conf/numa_conf.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c index 8fc3b0a196..3aae705a5d 100644 --- a/src/conf/numa_conf.c +++ b/src/conf/numa_conf.c @@ -714,7 +714,7 @@ virDomainNumaDefNodeDistanceParseXML(virDomainNumaPtr def, xmlNodePtr *nodes = NULL; size_t i, ndistances = def->nmem_nodes; - if (!ndistances) + if (ndistances == 0) return 0; /* check if NUMA distances definition is present */ @@ -805,11 +805,11 @@ virDomainNumaDefNodeDistanceParseXML(virDomainNumaPtr def, ldist[cur_cell].value = LOCAL_DISTANCE; ldist[cur_cell].cellid = cur_cell; def->mem_nodes[cur_cell].ndistances = ndistances; + def->mem_nodes[cur_cell].distances = ldist; } ldist[sibling_id].cellid = sibling_id; ldist[sibling_id].value = sibling_value; - def->mem_nodes[cur_cell].distances = ldist; /* Apply symmetry if none given */ rdist = def->mem_nodes[sibling_id].distances; @@ -820,20 +820,21 @@ virDomainNumaDefNodeDistanceParseXML(virDomainNumaPtr def, rdist[sibling_id].value = LOCAL_DISTANCE; rdist[sibling_id].cellid = sibling_id; def->mem_nodes[sibling_id].ndistances = ndistances; + def->mem_nodes[sibling_id].distances = rdist; } rdist[cur_cell].cellid = cur_cell; if (!rdist[cur_cell].value) rdist[cur_cell].value = sibling_value; - def->mem_nodes[sibling_id].distances = rdist; } ret = 0; cleanup: - if (ret) { + if (ret < 0) { for (i = 0; i < ndistances; i++) VIR_FREE(def->mem_nodes[i].distances); + def->mem_nodes[i].ndistances = 0; } VIR_FREE(nodes); VIR_FREE(tmp); -- 2.13.6 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list