From c74b898d4c947c5ff0c0edf9065d4294d9589ae3 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Fri, 17 May 2019 18:17:26 +0200 Subject: [PATCH] qemu: monitor: Use VIR_AUTOPTR in qemuMonitorJSON(Drive/Blockdev)Mirror MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- src/qemu/qemu_monitor_json.c | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 4152d44331..53a7de8b77 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -4280,9 +4280,8 @@ qemuMonitorJSONDriveMirror(qemuMonitorPtr mon, bool shallow, bool reuse) { - int ret = -1; - virJSONValuePtr cmd; - virJSONValuePtr reply = NULL; + VIR_AUTOPTR(virJSONValue) cmd = NULL; + VIR_AUTOPTR(virJSONValue) reply = NULL; cmd = qemuMonitorJSONMakeCommand("drive-mirror", "s:device", device, @@ -4298,16 +4297,9 @@ qemuMonitorJSONDriveMirror(qemuMonitorPtr mon, return -1; if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; - - if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; + return -1; - ret = 0; - cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); - return ret; + return qemuMonitorJSONCheckError(cmd, reply); } @@ -4321,9 +4313,8 @@ qemuMonitorJSONBlockdevMirror(qemuMonitorPtr mon, unsigned long long buf_size, bool shallow) { - int ret = -1; - virJSONValuePtr cmd; - virJSONValuePtr reply = NULL; + VIR_AUTOPTR(virJSONValue) cmd = NULL; + VIR_AUTOPTR(virJSONValue) reply = NULL; cmd = qemuMonitorJSONMakeCommand("blockdev-mirror", "S:job-id", jobname, @@ -4337,14 +4328,10 @@ qemuMonitorJSONBlockdevMirror(qemuMonitorPtr mon, if (!cmd) return -1; - if ((ret = qemuMonitorJSONCommand(mon, cmd, &reply)) < 0) - goto cleanup; - ret = qemuMonitorJSONCheckError(cmd, reply); + if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) + return -1; - cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); - return ret; + return qemuMonitorJSONCheckError(cmd, reply); } -- 2.47.2