提交 cda31f3d 编写于 作者: P Peter Krempa

qemuMonitorJSONCheckError: Use g_autofree

Eliminate cleanup code by using g_autofree.
Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
上级 9633dfbc
...@@ -393,8 +393,8 @@ qemuMonitorJSONCheckError(virJSONValuePtr cmd, ...@@ -393,8 +393,8 @@ qemuMonitorJSONCheckError(virJSONValuePtr cmd,
{ {
if (virJSONValueObjectHasKey(reply, "error")) { if (virJSONValueObjectHasKey(reply, "error")) {
virJSONValuePtr error = virJSONValueObjectGet(reply, "error"); virJSONValuePtr error = virJSONValueObjectGet(reply, "error");
char *cmdstr = virJSONValueToString(cmd, false); g_autofree char *cmdstr = virJSONValueToString(cmd, false);
char *replystr = virJSONValueToString(reply, false); g_autofree char *replystr = virJSONValueToString(reply, false);
/* Log the full JSON formatted command & error */ /* Log the full JSON formatted command & error */
VIR_DEBUG("unable to execute QEMU command %s: %s", VIR_DEBUG("unable to execute QEMU command %s: %s",
...@@ -411,20 +411,16 @@ qemuMonitorJSONCheckError(virJSONValuePtr cmd, ...@@ -411,20 +411,16 @@ qemuMonitorJSONCheckError(virJSONValuePtr cmd,
qemuMonitorJSONCommandName(cmd), qemuMonitorJSONCommandName(cmd),
qemuMonitorJSONStringifyError(error)); qemuMonitorJSONStringifyError(error));
VIR_FREE(cmdstr);
VIR_FREE(replystr);
return -1; return -1;
} else if (!virJSONValueObjectHasKey(reply, "return")) { } else if (!virJSONValueObjectHasKey(reply, "return")) {
char *cmdstr = virJSONValueToString(cmd, false); g_autofree char *cmdstr = virJSONValueToString(cmd, false);
char *replystr = virJSONValueToString(reply, false); g_autofree char *replystr = virJSONValueToString(reply, false);
VIR_DEBUG("Neither 'return' nor 'error' is set in the JSON reply %s: %s", VIR_DEBUG("Neither 'return' nor 'error' is set in the JSON reply %s: %s",
NULLSTR(cmdstr), NULLSTR(replystr)); NULLSTR(cmdstr), NULLSTR(replystr));
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("unable to execute QEMU command '%s'"), _("unable to execute QEMU command '%s'"),
qemuMonitorJSONCommandName(cmd)); qemuMonitorJSONCommandName(cmd));
VIR_FREE(cmdstr);
VIR_FREE(replystr);
return -1; return -1;
} }
return 0; return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册