提交 742494ee 编写于 作者: J John Ferlan

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.
上级 3eb84090
...@@ -714,7 +714,7 @@ virDomainNumaDefNodeDistanceParseXML(virDomainNumaPtr def, ...@@ -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, ...@@ -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, ...@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册