Rename 'cmd' to 'nsdef' and improve the control flow.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_domain.c | 29 ++++++++++++-----------------
1 file changed, 12 insertions(+), 17 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 5c4bca1c6a..ee8c9397e0 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -3205,8 +3205,8 @@ qemuDomainDefNamespaceParse(xmlDocPtr xml ATTRIBUTE_UNUSED,
xmlXPathContextPtr ctxt,
void **data)
{
- qemuDomainXmlNsDefPtr cmd = NULL;
- bool uses_qemu_ns = false;
+ qemuDomainXmlNsDefPtr nsdata = NULL;
+ int ret = -1;
if (xmlXPathRegisterNs(ctxt, BAD_CAST "qemu", BAD_CAST QEMU_NAMESPACE_HREF)
< 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -3215,26 +3215,21 @@ qemuDomainDefNamespaceParse(xmlDocPtr xml ATTRIBUTE_UNUSED,
return -1;
}
- if (VIR_ALLOC(cmd) < 0)
+ if (VIR_ALLOC(nsdata) < 0)
return -1;
- if (qemuDomainDefNamespaceParseCommandlineArgs(cmd, ctxt) < 0 ||
- qemuDomainDefNamespaceParseCommandlineEnv(cmd, ctxt) < 0)
- goto error;
-
- if (cmd->num_args > 0 || cmd->num_env > 0)
- uses_qemu_ns = true;
+ if (qemuDomainDefNamespaceParseCommandlineArgs(nsdata, ctxt) < 0 ||
+ qemuDomainDefNamespaceParseCommandlineEnv(nsdata, ctxt) < 0)
+ goto cleanup;
- if (uses_qemu_ns)
- *data = cmd;
- else
- VIR_FREE(cmd);
+ if (nsdata->num_args > 0 || nsdata->num_env > 0)
+ VIR_STEAL_PTR(*data, nsdata);
- return 0;
+ ret = 0;
- error:
- qemuDomainDefNamespaceFree(cmd);
- return -1;
+ cleanup:
+ qemuDomainDefNamespaceFree(nsdata);
+ return ret;
}
static int
--
2.21.0