mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
conf: Clean up virDomainNumaDefNodeDistanceParseXML
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.
This commit is contained in:
parent
3eb840904a
commit
742494eed8
@ -714,7 +714,7 @@ virDomainNumaDefNodeDistanceParseXML(virDomainNumaPtr def,
|
|||||||
xmlNodePtr *nodes = NULL;
|
xmlNodePtr *nodes = NULL;
|
||||||
size_t i, ndistances = def->nmem_nodes;
|
size_t i, ndistances = def->nmem_nodes;
|
||||||
|
|
||||||
if (!ndistances)
|
if (ndistances == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* check if NUMA distances definition is present */
|
/* check if NUMA distances definition is present */
|
||||||
@ -805,11 +805,11 @@ virDomainNumaDefNodeDistanceParseXML(virDomainNumaPtr def,
|
|||||||
ldist[cur_cell].value = LOCAL_DISTANCE;
|
ldist[cur_cell].value = LOCAL_DISTANCE;
|
||||||
ldist[cur_cell].cellid = cur_cell;
|
ldist[cur_cell].cellid = cur_cell;
|
||||||
def->mem_nodes[cur_cell].ndistances = ndistances;
|
def->mem_nodes[cur_cell].ndistances = ndistances;
|
||||||
|
def->mem_nodes[cur_cell].distances = ldist;
|
||||||
}
|
}
|
||||||
|
|
||||||
ldist[sibling_id].cellid = sibling_id;
|
ldist[sibling_id].cellid = sibling_id;
|
||||||
ldist[sibling_id].value = sibling_value;
|
ldist[sibling_id].value = sibling_value;
|
||||||
def->mem_nodes[cur_cell].distances = ldist;
|
|
||||||
|
|
||||||
/* Apply symmetry if none given */
|
/* Apply symmetry if none given */
|
||||||
rdist = def->mem_nodes[sibling_id].distances;
|
rdist = def->mem_nodes[sibling_id].distances;
|
||||||
@ -820,20 +820,21 @@ virDomainNumaDefNodeDistanceParseXML(virDomainNumaPtr def,
|
|||||||
rdist[sibling_id].value = LOCAL_DISTANCE;
|
rdist[sibling_id].value = LOCAL_DISTANCE;
|
||||||
rdist[sibling_id].cellid = sibling_id;
|
rdist[sibling_id].cellid = sibling_id;
|
||||||
def->mem_nodes[sibling_id].ndistances = ndistances;
|
def->mem_nodes[sibling_id].ndistances = ndistances;
|
||||||
|
def->mem_nodes[sibling_id].distances = rdist;
|
||||||
}
|
}
|
||||||
|
|
||||||
rdist[cur_cell].cellid = cur_cell;
|
rdist[cur_cell].cellid = cur_cell;
|
||||||
if (!rdist[cur_cell].value)
|
if (!rdist[cur_cell].value)
|
||||||
rdist[cur_cell].value = sibling_value;
|
rdist[cur_cell].value = sibling_value;
|
||||||
def->mem_nodes[sibling_id].distances = rdist;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (ret) {
|
if (ret < 0) {
|
||||||
for (i = 0; i < ndistances; i++)
|
for (i = 0; i < ndistances; i++)
|
||||||
VIR_FREE(def->mem_nodes[i].distances);
|
VIR_FREE(def->mem_nodes[i].distances);
|
||||||
|
def->mem_nodes[i].ndistances = 0;
|
||||||
}
|
}
|
||||||
VIR_FREE(nodes);
|
VIR_FREE(nodes);
|
||||||
VIR_FREE(tmp);
|
VIR_FREE(tmp);
|
||||||
|
Loading…
Reference in New Issue
Block a user