From: Peter Krempa Date: Tue, 20 Apr 2021 14:16:56 +0000 (+0200) Subject: qemuMonitorJSONBlockJobCancel: Refactor cleanup X-Git-Tag: v7.3.0-rc1~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2587f825de41c3547bef59fe48bfa811e6993857;p=thirdparty%2Flibvirt.git qemuMonitorJSONBlockJobCancel: Refactor cleanup Use automatic memory freeing and remove the cleanup section. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 652034472a..8f3ccb0c63 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -5219,9 +5219,8 @@ int qemuMonitorJSONBlockJobCancel(qemuMonitor *mon, const char *jobname) { - int ret = -1; - virJSONValue *cmd = NULL; - virJSONValue *reply = NULL; + g_autoptr(virJSONValue) cmd = NULL; + g_autoptr(virJSONValue) reply = NULL; if (!(cmd = qemuMonitorJSONMakeCommand("block-job-cancel", "s:device", jobname, @@ -5229,17 +5228,12 @@ qemuMonitorJSONBlockJobCancel(qemuMonitor *mon, return -1; if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; if (qemuMonitorJSONBlockJobError(cmd, reply, jobname) < 0) - goto cleanup; - - ret = 0; + return -1; - cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); - return ret; + return 0; }