mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-24 05:25:18 +00:00
cpu_map: Use g_auto* in loadData
Signed-off-by: Tim Wiederhake <twiederh@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com> Signed-off-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
ddbff7e3ee
commit
239218c567
@ -39,20 +39,19 @@ loadData(const char *mapfile,
|
|||||||
cpuMapLoadCallback callback,
|
cpuMapLoadCallback callback,
|
||||||
void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
|
||||||
VIR_XPATH_NODE_AUTORESTORE(ctxt)
|
VIR_XPATH_NODE_AUTORESTORE(ctxt)
|
||||||
xmlNodePtr *nodes = NULL;
|
g_autofree xmlNodePtr *nodes = NULL;
|
||||||
int n;
|
int n;
|
||||||
size_t i;
|
size_t i;
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
if ((n = virXPathNodeSet(element, ctxt, &nodes)) < 0)
|
if ((n = virXPathNodeSet(element, ctxt, &nodes)) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (n > 0 && !callback) {
|
if (n > 0 && !callback) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Unexpected element '%s' in CPU map '%s'"), element, mapfile);
|
_("Unexpected element '%s' in CPU map '%s'"), element, mapfile);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
@ -60,22 +59,17 @@ loadData(const char *mapfile,
|
|||||||
if (!name) {
|
if (!name) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("cannot find %s name in CPU map '%s'"), element, mapfile);
|
_("cannot find %s name in CPU map '%s'"), element, mapfile);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
VIR_DEBUG("Load %s name %s", element, name);
|
VIR_DEBUG("Load %s name %s", element, name);
|
||||||
ctxt->node = nodes[i];
|
ctxt->node = nodes[i];
|
||||||
rv = callback(ctxt, name, data);
|
rv = callback(ctxt, name, data);
|
||||||
VIR_FREE(name);
|
VIR_FREE(name);
|
||||||
if (rv < 0)
|
if (rv < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
VIR_FREE(nodes);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
Loading…
x
Reference in New Issue
Block a user