d76c62
From 21199b5d14d4d21d2a1bdf9f17767d3c4b0bc00d Mon Sep 17 00:00:00 2001
d76c62
Message-Id: <21199b5d14d4d21d2a1bdf9f17767d3c4b0bc00d@dist-git>
d76c62
From: Peter Krempa <pkrempa@redhat.com>
d76c62
Date: Wed, 19 Feb 2020 15:10:03 +0100
d76c62
Subject: [PATCH] qemuMonitorJSONBlockdevDel: Refactor cleanup
d76c62
MIME-Version: 1.0
d76c62
Content-Type: text/plain; charset=UTF-8
d76c62
Content-Transfer-Encoding: 8bit
d76c62
d76c62
Use automatic variable freeing and get rid of the cleanup section.
d76c62
d76c62
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
d76c62
Reviewed-by: Ján Tomko <jtomko@redhat.com>
d76c62
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
d76c62
(cherry picked from commit a592d589aa5015f5beb0f1d4302ceffe9fe7f7e8)
d76c62
d76c62
https://bugzilla.redhat.com/show_bug.cgi?id=1798366
d76c62
Message-Id: <e997465c781bb23dad07483313a29f4df2df9a1c.1582120424.git.pkrempa@redhat.com>
d76c62
Reviewed-by: Ján Tomko <jtomko@redhat.com>
d76c62
---
d76c62
 src/qemu/qemu_monitor_json.c | 16 +++++-----------
d76c62
 1 file changed, 5 insertions(+), 11 deletions(-)
d76c62
d76c62
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
d76c62
index ad490dd324..05a44882f0 100644
d76c62
--- a/src/qemu/qemu_monitor_json.c
d76c62
+++ b/src/qemu/qemu_monitor_json.c
d76c62
@@ -8833,9 +8833,8 @@ int
d76c62
 qemuMonitorJSONBlockdevDel(qemuMonitorPtr mon,
d76c62
                            const char *nodename)
d76c62
 {
d76c62
-    virJSONValuePtr cmd;
d76c62
-    virJSONValuePtr reply = NULL;
d76c62
-    int ret = -1;
d76c62
+    g_autoptr(virJSONValue) cmd = NULL;
d76c62
+    g_autoptr(virJSONValue) reply = NULL;
d76c62
 
d76c62
     if (!(cmd = qemuMonitorJSONMakeCommand("blockdev-del",
d76c62
                                            "s:node-name", nodename,
d76c62
@@ -8843,17 +8842,12 @@ qemuMonitorJSONBlockdevDel(qemuMonitorPtr mon,
d76c62
         return -1;
d76c62
 
d76c62
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
d76c62
-        goto cleanup;
d76c62
+        return -1;
d76c62
 
d76c62
     if (qemuMonitorJSONCheckError(cmd, reply) < 0)
d76c62
-        goto cleanup;
d76c62
+        return -1;
d76c62
 
d76c62
-    ret = 0;
d76c62
-
d76c62
- cleanup:
d76c62
-    virJSONValueFree(cmd);
d76c62
-    virJSONValueFree(reply);
d76c62
-    return ret;
d76c62
+    return 0;
d76c62
 }
d76c62
 
d76c62
 
d76c62
-- 
d76c62
2.25.0
d76c62