mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
cpu_map: Use g_auto* in cpuMapLoad
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
090fd6a413
commit
36f922ef8e
@ -169,12 +169,11 @@ int cpuMapLoad(const char *arch,
|
|||||||
cpuMapLoadCallback modelCB,
|
cpuMapLoadCallback modelCB,
|
||||||
void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
xmlDocPtr xml = NULL;
|
g_autoptr(xmlDoc) xml = NULL;
|
||||||
xmlXPathContextPtr ctxt = NULL;
|
g_autoptr(xmlXPathContext) ctxt = NULL;
|
||||||
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
||||||
char *xpath = NULL;
|
g_autofree char *xpath = NULL;
|
||||||
int ret = -1;
|
g_autofree char *mapfile = NULL;
|
||||||
char *mapfile;
|
|
||||||
|
|
||||||
if (!(mapfile = virFileFindResource("index.xml",
|
if (!(mapfile = virFileFindResource("index.xml",
|
||||||
abs_top_srcdir "/src/cpu_map",
|
abs_top_srcdir "/src/cpu_map",
|
||||||
@ -186,11 +185,11 @@ int cpuMapLoad(const char *arch,
|
|||||||
if (arch == NULL) {
|
if (arch == NULL) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"%s", _("undefined hardware architecture"));
|
"%s", _("undefined hardware architecture"));
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(xml = virXMLParseFileCtxt(mapfile, &ctxt)))
|
if (!(xml = virXMLParseFileCtxt(mapfile, &ctxt)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
virBufferAsprintf(&buf, "./arch[@name='%s']", arch);
|
virBufferAsprintf(&buf, "./arch[@name='%s']", arch);
|
||||||
|
|
||||||
@ -201,28 +200,20 @@ int cpuMapLoad(const char *arch,
|
|||||||
if ((ctxt->node = virXPathNode(xpath, ctxt)) == NULL) {
|
if ((ctxt->node = virXPathNode(xpath, ctxt)) == NULL) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("cannot find CPU map for %s architecture"), arch);
|
_("cannot find CPU map for %s architecture"), arch);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (loadData(mapfile, ctxt, "vendor", vendorCB, data) < 0)
|
if (loadData(mapfile, ctxt, "vendor", vendorCB, data) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (loadData(mapfile, ctxt, "feature", featureCB, data) < 0)
|
if (loadData(mapfile, ctxt, "feature", featureCB, data) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (loadData(mapfile, ctxt, "model", modelCB, data) < 0)
|
if (loadData(mapfile, ctxt, "model", modelCB, data) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (loadIncludes(ctxt, vendorCB, featureCB, modelCB, data) < 0)
|
if (loadIncludes(ctxt, vendorCB, featureCB, modelCB, data) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
xmlXPathFreeContext(ctxt);
|
|
||||||
xmlFreeDoc(xml);
|
|
||||||
VIR_FREE(xpath);
|
|
||||||
VIR_FREE(mapfile);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user