mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 11:22:23 +00:00
cpu_ppc64.c: use g_autofree() whenever possible
This allows for a label removal in ppc64ModelParse(). Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com> Reviewed-by: Ján Tomko <jtomko@redhat.com> Signed-off-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
ec79c3338b
commit
c9491341af
@ -308,22 +308,21 @@ ppc64ModelParse(xmlXPathContextPtr ctxt,
|
||||
{
|
||||
virCPUppc64MapPtr map = data;
|
||||
g_autoptr(virCPUppc64Model) model = NULL;
|
||||
xmlNodePtr *nodes = NULL;
|
||||
char *vendor = NULL;
|
||||
g_autofree xmlNodePtr *nodes = NULL;
|
||||
g_autofree char *vendor = NULL;
|
||||
unsigned long pvr;
|
||||
size_t i;
|
||||
int n;
|
||||
int ret = -1;
|
||||
|
||||
if (VIR_ALLOC(model) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
model->name = g_strdup(name);
|
||||
|
||||
if (ppc64ModelFind(map, model->name)) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("CPU model %s already defined"), model->name);
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (virXPathBoolean("boolean(./vendor)", ctxt)) {
|
||||
@ -332,14 +331,14 @@ ppc64ModelParse(xmlXPathContextPtr ctxt,
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Invalid vendor element in CPU model %s"),
|
||||
model->name);
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!(model->vendor = ppc64VendorFind(map, vendor))) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Unknown vendor %s referenced by CPU model %s"),
|
||||
vendor, model->name);
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -347,11 +346,11 @@ ppc64ModelParse(xmlXPathContextPtr ctxt,
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Missing PVR information for CPU model %s"),
|
||||
model->name);
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (VIR_ALLOC_N(model->data.pvr, n) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
model->data.len = n;
|
||||
|
||||
@ -362,7 +361,7 @@ ppc64ModelParse(xmlXPathContextPtr ctxt,
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Missing or invalid PVR value in CPU model %s"),
|
||||
model->name);
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
model->data.pvr[i].value = pvr;
|
||||
|
||||
@ -370,20 +369,15 @@ ppc64ModelParse(xmlXPathContextPtr ctxt,
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Missing or invalid PVR mask in CPU model %s"),
|
||||
model->name);
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
model->data.pvr[i].mask = pvr;
|
||||
}
|
||||
|
||||
if (VIR_APPEND_ELEMENT(map->models, map->nmodels, model) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
VIR_FREE(vendor);
|
||||
VIR_FREE(nodes);
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -547,7 +541,7 @@ virCPUppc64Compare(virCPUDefPtr host,
|
||||
bool failIncompatible)
|
||||
{
|
||||
virCPUCompareResult ret;
|
||||
char *message = NULL;
|
||||
g_autofree char *message = NULL;
|
||||
|
||||
if (!host || !host->model) {
|
||||
if (failIncompatible) {
|
||||
@ -570,7 +564,6 @@ virCPUppc64Compare(virCPUDefPtr host,
|
||||
virReportError(VIR_ERR_CPU_INCOMPATIBLE, NULL);
|
||||
}
|
||||
}
|
||||
VIR_FREE(message);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user