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:
Tim Wiederhake 2020-09-11 15:22:43 +02:00 committed by Ján Tomko
parent 43250af8dd
commit fc8e0cad0c

View File

@ -55,8 +55,9 @@ loadData(const char *mapfile,
} }
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
char *name = virXMLPropString(nodes[i], "name"); g_autofree char *name = NULL;
if (!name) {
if (!(name = virXMLPropString(nodes[i], "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);
return -1; return -1;
@ -64,7 +65,6 @@ loadData(const char *mapfile,
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);
if (rv < 0) if (rv < 0)
return -1; return -1;
} }