From d5c9acc16644013d4e92f5678600dcb15f798b96 Mon Sep 17 00:00:00 2001 From: Jiri Denemark Date: Fri, 19 Mar 2021 23:28:38 +0100 Subject: [PATCH] qemu: Use g_autoptr in qemuMonitorJSONSetCapabilities Signed-off-by: Jiri Denemark Reviewed-by: Erik Skultety --- src/qemu/qemu_monitor_json.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index b669630bc8..5e7f425495 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -1644,23 +1644,20 @@ qemuMonitorJSONHumanCommand(qemuMonitorPtr mon, int qemuMonitorJSONSetCapabilities(qemuMonitorPtr mon) { - int ret = -1; - virJSONValuePtr cmd = qemuMonitorJSONMakeCommand("qmp_capabilities", NULL); - virJSONValuePtr reply = NULL; - if (!cmd) + g_autoptr(virJSONValue) cmd = NULL; + g_autoptr(virJSONValue) reply = NULL; + + if (!(cmd = qemuMonitorJSONMakeCommand("qmp_capabilities", + NULL))) return -1; if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; + return -1; - ret = 0; - cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); - return ret; + return 0; }