From: Peter Krempa Date: Thu, 6 Feb 2020 12:03:07 +0000 (+0100) Subject: qemuMonitorJSONBlockdevDel: Refactor cleanup X-Git-Tag: v6.1.0-rc1~181 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a592d589aa5015f5beb0f1d4302ceffe9fe7f7e8;p=thirdparty%2Flibvirt.git qemuMonitorJSONBlockdevDel: Refactor cleanup 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 --- diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 6a439727c7..bbcb67ddb7 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -8843,9 +8843,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, @@ -8853,17 +8852,12 @@ qemuMonitorJSONBlockdevDel(qemuMonitorPtr mon, return -1; if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; - - ret = 0; + return -1; - cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); - return ret; + return 0; }