提交 8b0a389d 编写于 作者: P Peter Krempa

qemu: Refactor qemuDomainDefNamespaceParse

Rename 'cmd' to 'nsdef' and improve the control flow.
Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 a858b777
...@@ -3201,8 +3201,8 @@ qemuDomainDefNamespaceParse(xmlDocPtr xml ATTRIBUTE_UNUSED, ...@@ -3201,8 +3201,8 @@ qemuDomainDefNamespaceParse(xmlDocPtr xml ATTRIBUTE_UNUSED,
xmlXPathContextPtr ctxt, xmlXPathContextPtr ctxt,
void **data) void **data)
{ {
qemuDomainXmlNsDefPtr cmd = NULL; qemuDomainXmlNsDefPtr nsdata = NULL;
bool uses_qemu_ns = false; int ret = -1;
if (xmlXPathRegisterNs(ctxt, BAD_CAST "qemu", BAD_CAST QEMU_NAMESPACE_HREF) < 0) { if (xmlXPathRegisterNs(ctxt, BAD_CAST "qemu", BAD_CAST QEMU_NAMESPACE_HREF) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
...@@ -3211,26 +3211,21 @@ qemuDomainDefNamespaceParse(xmlDocPtr xml ATTRIBUTE_UNUSED, ...@@ -3211,26 +3211,21 @@ qemuDomainDefNamespaceParse(xmlDocPtr xml ATTRIBUTE_UNUSED,
return -1; return -1;
} }
if (VIR_ALLOC(cmd) < 0) if (VIR_ALLOC(nsdata) < 0)
return -1; return -1;
if (qemuDomainDefNamespaceParseCommandlineArgs(cmd, ctxt) < 0 || if (qemuDomainDefNamespaceParseCommandlineArgs(nsdata, ctxt) < 0 ||
qemuDomainDefNamespaceParseCommandlineEnv(cmd, ctxt) < 0) qemuDomainDefNamespaceParseCommandlineEnv(nsdata, ctxt) < 0)
goto error; goto cleanup;
if (cmd->num_args > 0 || cmd->num_env > 0)
uses_qemu_ns = true;
if (uses_qemu_ns) if (nsdata->num_args > 0 || nsdata->num_env > 0)
*data = cmd; VIR_STEAL_PTR(*data, nsdata);
else
VIR_FREE(cmd);
return 0; ret = 0;
error: cleanup:
qemuDomainDefNamespaceFree(cmd); qemuDomainDefNamespaceFree(nsdata);
return -1; return ret;
} }
static int static int
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册