[PATCH 4/8] qemuMonitorJSONBlockStatsUpdateCapacityOne: Refactor cleanup

Peter Krempa pkrempa at redhat.com
Tue Oct 19 14:43:11 UTC 2021


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

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/qemu/qemu_monitor_json.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index af6e918e06..e4f4dba79a 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -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;
 }


-- 
2.31.1




More information about the libvir-list mailing list