From 21199b5d14d4d21d2a1bdf9f17767d3c4b0bc00d Mon Sep 17 00:00:00 2001 Message-Id: <21199b5d14d4d21d2a1bdf9f17767d3c4b0bc00d@dist-git> From: Peter Krempa Date: Wed, 19 Feb 2020 15:10:03 +0100 Subject: [PATCH] qemuMonitorJSONBlockdevDel: Refactor cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use automatic variable freeing and get rid of the cleanup section. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko Reviewed-by: Daniel Henrique Barboza (cherry picked from commit a592d589aa5015f5beb0f1d4302ceffe9fe7f7e8) https://bugzilla.redhat.com/show_bug.cgi?id=1798366 Message-Id: Reviewed-by: Ján Tomko --- src/qemu/qemu_monitor_json.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index ad490dd324..05a44882f0 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -8833,9 +8833,8 @@ int qemuMonitorJSONBlockdevDel(qemuMonitorPtr mon, const char *nodename) { - virJSONValuePtr cmd; - virJSONValuePtr reply = NULL; - int ret = -1; + g_autoptr(virJSONValue) cmd = NULL; + g_autoptr(virJSONValue) reply = NULL; if (!(cmd = qemuMonitorJSONMakeCommand("blockdev-del", "s:node-name", nodename, @@ -8843,17 +8842,12 @@ qemuMonitorJSONBlockdevDel(qemuMonitorPtr mon, 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; } -- 2.25.0