Use 'g_autofree' in the 'str' parameter and remove the 'cleanup'
label.
Signed-off-by: Daniel Henrique Barboza <danielhb413(a)gmail.com>
---
src/qemu/qemu_capabilities.c | 29 +++++++++++------------------
1 file changed, 11 insertions(+), 18 deletions(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index aef76ecc56..5257fe64b2 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -3723,21 +3723,18 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsAccel *caps,
xmlXPathContextPtr ctxt,
const char *typeStr)
{
- char *str = NULL;
+ g_autofree char *str = NULL;
xmlNodePtr hostCPUNode;
g_autofree xmlNodePtr *nodes = NULL;
VIR_XPATH_NODE_AUTORESTORE(ctxt)
g_autoptr(qemuMonitorCPUModelInfo) hostCPU = NULL;
g_autofree char *xpath = g_strdup_printf("./hostCPU[@type='%s']",
typeStr);
- int ret = -1;
size_t i;
int n;
int val;
- if (!(hostCPUNode = virXPathNode(xpath, ctxt))) {
- ret = 0;
- goto cleanup;
- }
+ if (!(hostCPUNode = virXPathNode(xpath, ctxt)))
+ return 0;
hostCPU = g_new0(qemuMonitorCPUModelInfo, 1);
@@ -3745,14 +3742,14 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsAccel *caps,
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("missing host CPU model name in QEMU "
"capabilities cache"));
- goto cleanup;
+ return -1;
}
if (!(str = virXMLPropString(hostCPUNode, "migratability")) ||
(val = virTristateBoolTypeFromString(str)) <= 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("invalid migratability value for host CPU model"));
- goto cleanup;
+ return -1;
}
hostCPU->migratability = val == VIR_TRISTATE_BOOL_YES;
VIR_FREE(str);
@@ -3772,7 +3769,7 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsAccel *caps,
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("missing 'name' attribute for a host
CPU"
" model property in QEMU capabilities
cache"));
- goto cleanup;
+ return -1;
}
if (!(str = virXMLPropString(ctxt->node, "type")) ||
@@ -3780,7 +3777,7 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsAccel *caps,
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("missing or invalid CPU model property type "
"in QEMU capabilities cache"));
- goto cleanup;
+ return -1;
}
VIR_FREE(str);
@@ -3798,7 +3795,7 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsAccel *caps,
_("invalid string value for '%s' host CPU
"
"model property in QEMU capabilities
cache"),
prop->name);
- goto cleanup;
+ return -1;
}
break;
@@ -3809,7 +3806,7 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsAccel *caps,
_("invalid number value for '%s' host CPU
"
"model property in QEMU capabilities
cache"),
prop->name);
- goto cleanup;
+ return -1;
}
break;
@@ -3823,7 +3820,7 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsAccel *caps,
_("unknown migratable value for '%s' host
"
"CPU model property"),
prop->name);
- goto cleanup;
+ return -1;
}
prop->migratable = val;
@@ -3833,11 +3830,7 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsAccel *caps,
}
caps->hostCPU.info = g_steal_pointer(&hostCPU);
- ret = 0;
-
- cleanup:
- VIR_FREE(str);
- return ret;
+ return 0;
}
--
2.31.1