]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuMonitorJSONBlockdevDel: Refactor cleanup
authorPeter Krempa <pkrempa@redhat.com>
Thu, 6 Feb 2020 12:03:07 +0000 (13:03 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 10 Feb 2020 16:26:27 +0000 (17:26 +0100)
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>
src/qemu/qemu_monitor_json.c

index 6a439727c78a3db3cc452d872503206d606c05dd..bbcb67ddb797a0a16bfabea2ddb6288252c214bc 100644 (file)
@@ -8843,9 +8843,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,
@@ -8853,17 +8852,12 @@ qemuMonitorJSONBlockdevDel(qemuMonitorPtr mon,
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONCheckError(cmd, reply) < 0)
-        goto cleanup;
-
-    ret = 0;
+        return -1;
 
- cleanup:
-    virJSONValueFree(cmd);
-    virJSONValueFree(reply);
-    return ret;
+    return 0;
 }