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