mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
cpu_x86: Use g_auto* in virCPUx86DataParse
Signed-off-by: Jiri Denemark <jdenemar@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
3c650a8f7a
commit
c1532711dd
@ -1636,8 +1636,8 @@ virCPUx86DataFormat(const virCPUData *data)
|
|||||||
static virCPUDataPtr
|
static virCPUDataPtr
|
||||||
virCPUx86DataParse(xmlXPathContextPtr ctxt)
|
virCPUx86DataParse(xmlXPathContextPtr ctxt)
|
||||||
{
|
{
|
||||||
xmlNodePtr *nodes = NULL;
|
g_autofree xmlNodePtr *nodes = NULL;
|
||||||
virCPUDataPtr cpuData = NULL;
|
g_autoptr(virCPUData) cpuData = NULL;
|
||||||
virCPUx86DataItem item;
|
virCPUx86DataItem item;
|
||||||
size_t i;
|
size_t i;
|
||||||
int n;
|
int n;
|
||||||
@ -1646,11 +1646,11 @@ virCPUx86DataParse(xmlXPathContextPtr ctxt)
|
|||||||
if (n <= 0) {
|
if (n <= 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("no x86 CPU data found"));
|
_("no x86 CPU data found"));
|
||||||
goto error;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(cpuData = virCPUDataNew(VIR_ARCH_X86_64)))
|
if (!(cpuData = virCPUDataNew(VIR_ARCH_X86_64)))
|
||||||
goto error;
|
return NULL;
|
||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
ctxt->node = nodes[i];
|
ctxt->node = nodes[i];
|
||||||
@ -1658,28 +1658,21 @@ virCPUx86DataParse(xmlXPathContextPtr ctxt)
|
|||||||
if (x86ParseCPUID(ctxt, &item) < 0) {
|
if (x86ParseCPUID(ctxt, &item) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("failed to parse cpuid[%zu]"), i);
|
_("failed to parse cpuid[%zu]"), i);
|
||||||
goto error;
|
return NULL;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (x86ParseMSR(ctxt, &item) < 0) {
|
if (x86ParseMSR(ctxt, &item) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("failed to parse msr[%zu]"), i);
|
_("failed to parse msr[%zu]"), i);
|
||||||
goto error;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virCPUx86DataAdd(cpuData, &item) < 0)
|
if (virCPUx86DataAdd(cpuData, &item) < 0)
|
||||||
goto error;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
return g_steal_pointer(&cpuData);
|
||||||
VIR_FREE(nodes);
|
|
||||||
return cpuData;
|
|
||||||
|
|
||||||
error:
|
|
||||||
virCPUx86DataFree(cpuData);
|
|
||||||
cpuData = NULL;
|
|
||||||
goto cleanup;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user