]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuMonitorJSONBlockStatsUpdateCapacity: Refactor cleanup
authorPeter Krempa <pkrempa@redhat.com>
Tue, 19 Oct 2021 12:48:16 +0000 (14:48 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 20 Oct 2021 11:43:37 +0000 (13:43 +0200)
Use automatic memory clearing for the temporary variable and remove the
cleanup section.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_monitor_json.c

index 579d986e022e09a8210761164c82c380ac998ad7..af6e918e06f94b6513b627f8fc600731b63d80ce 100644 (file)
@@ -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;
 }