diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 4152d443315f28c62ca6f2d79924f005720712d1..53a7de8b7740adc60c5b56ca3e9777617407d2f3 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); }