From 21199b5d14d4d21d2a1bdf9f17767d3c4b0bc00d Mon Sep 17 00:00:00 2001
Message-Id: <21199b5d14d4d21d2a1bdf9f17767d3c4b0bc00d@dist-git>
From: Peter Krempa <pkrempa@redhat.com>
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 <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
(cherry picked from commit a592d589aa5015f5beb0f1d4302ceffe9fe7f7e8)
https://bugzilla.redhat.com/show_bug.cgi?id=1798366
Message-Id: <e997465c781bb23dad07483313a29f4df2df9a1c.1582120424.git.pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
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