]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuMonitorJSONBlockStatsUpdateCapacityOne: 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 af6e918e06f94b6513b627f8fc600731b63d80ce..e4f4dba79a594f432171810c4811481fb4649985 100644 (file)
@@ -2631,13 +2631,12 @@ qemuMonitorJSONBlockStatsUpdateCapacityOne(virJSONValue *image,
                                            GHashTable *stats,
                                            bool backingChain)
 {
-    int ret = -1;
-    char *entry_name = qemuDomainStorageAlias(dev_name, depth);
+    g_autofree char *entry_name = qemuDomainStorageAlias(dev_name, depth);
     virJSONValue *backing;
 
     if (qemuMonitorJSONBlockStatsUpdateCapacityData(image, entry_name,
                                                     stats, NULL) < 0)
-        goto cleanup;
+        return -1;
 
     if (backingChain &&
         (backing = virJSONValueObjectGetObject(image, "backing-image")) &&
@@ -2646,12 +2645,9 @@ qemuMonitorJSONBlockStatsUpdateCapacityOne(virJSONValue *image,
                                                    depth + 1,
                                                    stats,
                                                    true) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
- cleanup:
-    VIR_FREE(entry_name);
-    return ret;
+    return 0;
 }