[PATCH 3/8] qemuMonitorJSONBlockStatsUpdateCapacity: Refactor cleanup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use automatic memory clearing for the temporary variable and remove the
cleanup section.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_monitor_json.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 579d986e02..af6e918e06 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -2660,9 +2660,8 @@ qemuMonitorJSONBlockStatsUpdateCapacity(qemuMonitor *mon,
                                         GHashTable *stats,
                                         bool backingChain)
 {
-    int ret = -1;
     size_t i;
-    virJSONValue *devices;
+    g_autoptr(virJSONValue) devices = NULL;

     if (!(devices = qemuMonitorJSONQueryBlock(mon)))
         return -1;
@@ -2674,10 +2673,10 @@ qemuMonitorJSONBlockStatsUpdateCapacity(qemuMonitor *mon,
         const char *dev_name;

         if (!(dev = qemuMonitorJSONGetBlockDev(devices, i)))
-            goto cleanup;
+            return -1;

         if (!(dev_name = qemuMonitorJSONGetBlockDevDevice(dev)))
-            goto cleanup;
+            return -1;

         /* drive may be empty */
         if (!(inserted = virJSONValueObjectGetObject(dev, "inserted")) ||
@@ -2687,14 +2686,10 @@ qemuMonitorJSONBlockStatsUpdateCapacity(qemuMonitor *mon,
         if (qemuMonitorJSONBlockStatsUpdateCapacityOne(image, dev_name, 0,
                                                        stats,
                                                        backingChain) < 0)
-            goto cleanup;
+            return -1;
     }

-    ret = 0;
-
- cleanup:
-    virJSONValueFree(devices);
-    return ret;
+    return 0;
 }


-- 
2.31.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux