conf: node_device: cleanup virNodeDevCapCCWParseXML

Make use of g_autofree

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Boris Fiuczynski 2020-10-23 19:31:51 +02:00 committed by Ján Tomko
parent b5f8c358a3
commit 4694299234

View File

@ -850,57 +850,52 @@ virNodeDevCapCCWParseXML(xmlXPathContextPtr ctxt,
virNodeDevCapCCWPtr ccw_dev)
{
VIR_XPATH_NODE_AUTORESTORE(ctxt)
int ret = -1;
char *cssid = NULL, *ssid = NULL, *devno = NULL;
g_autofree char *cssid = NULL;
g_autofree char *ssid = NULL;
g_autofree char *devno = NULL;
ctxt->node = node;
if (!(cssid = virXPathString("string(./cssid[1])", ctxt))) {
if (!(cssid = virXPathString("string(./cssid[1])", ctxt))) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("missing cssid value for '%s'"), def->name);
goto out;
return -1;
}
if (virStrToLong_uip(cssid, NULL, 0, &ccw_dev->cssid) < 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("invalid cssid value '%s' for '%s'"),
cssid, def->name);
goto out;
return -1;
}
if (!(ssid = virXPathString("string(./ssid[1])", ctxt))) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("missing ssid value for '%s'"), def->name);
goto out;
return -1;
}
if (virStrToLong_uip(ssid, NULL, 0, &ccw_dev->ssid) < 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("invalid ssid value '%s' for '%s'"),
cssid, def->name);
goto out;
return -1;
}
if (!(devno = virXPathString("string(./devno[1])", ctxt))) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("missing devno value for '%s'"), def->name);
goto out;
return -1;
}
if (virStrToLong_uip(devno, NULL, 16, &ccw_dev->devno) < 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("invalid devno value '%s' for '%s'"),
devno, def->name);
goto out;
return -1;
}
ret = 0;
out:
VIR_FREE(cssid);
VIR_FREE(ssid);
VIR_FREE(devno);
return ret;
return 0;
}