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

testQemuMonitorJSONqemuMonitorJSONGetTargetArch: Fix uninitialized use of 'arch'

Refactor the cleanup control flow and use g_autofree for 'arch' so that
it's mandated that it's initialized.
Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 1a53b2ba
...@@ -2162,8 +2162,7 @@ testQemuMonitorJSONqemuMonitorJSONGetTargetArch(const void *opaque) ...@@ -2162,8 +2162,7 @@ testQemuMonitorJSONqemuMonitorJSONGetTargetArch(const void *opaque)
{ {
const testGenericData *data = opaque; const testGenericData *data = opaque;
virDomainXMLOptionPtr xmlopt = data->xmlopt; virDomainXMLOptionPtr xmlopt = data->xmlopt;
int ret = -1; g_autofree char *arch = NULL;
char *arch;
g_autoptr(qemuMonitorTest) test = NULL; g_autoptr(qemuMonitorTest) test = NULL;
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema))) if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
...@@ -2176,22 +2175,19 @@ testQemuMonitorJSONqemuMonitorJSONGetTargetArch(const void *opaque) ...@@ -2176,22 +2175,19 @@ testQemuMonitorJSONqemuMonitorJSONGetTargetArch(const void *opaque)
" }," " },"
" \"id\": \"libvirt-21\"" " \"id\": \"libvirt-21\""
"}") < 0) "}") < 0)
goto cleanup; return -1;
if (!(arch = qemuMonitorJSONGetTargetArch(qemuMonitorTestGetMonitor(test)))) if (!(arch = qemuMonitorJSONGetTargetArch(qemuMonitorTestGetMonitor(test))))
goto cleanup; return -1;
if (STRNEQ(arch, "x86_64")) { if (STRNEQ(arch, "x86_64")) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
"Unexpected architecture %s, expecting x86_64", "Unexpected architecture %s, expecting x86_64",
arch); arch);
goto cleanup; return -1;
} }
ret = 0; return 0;
cleanup:
VIR_FREE(arch);
return ret;
} }
static int static int
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册