[PATCH 07/11] qemu: block: Add and use AUTOPTR func for qemuBlockNodeNameBackingChainData

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

 



This is a locally used helper struct but we can make use of automatic
freeing for it.

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

diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
index 822ba44e18..2017eca139 100644
--- a/src/qemu/qemu_block.c
+++ b/src/qemu/qemu_block.c
@@ -88,6 +88,9 @@ qemuBlockNodeNameBackingChainDataFree(qemuBlockNodeNameBackingChainDataPtr data)
     VIR_FREE(data);
 }

+VIR_DEFINE_AUTOPTR_FUNC(qemuBlockNodeNameBackingChainData,
+                        qemuBlockNodeNameBackingChainDataFree);
+

 static void
 qemuBlockNodeNameBackingChainDataHashEntryFree(void *opaque,
@@ -128,7 +131,7 @@ qemuBlockNodeNameGetBackingChainBacking(virJSONValuePtr next,
                                         virHashTablePtr nodenamestable,
                                         qemuBlockNodeNameBackingChainDataPtr *nodenamedata)
 {
-    qemuBlockNodeNameBackingChainDataPtr data = NULL;
+    VIR_AUTOPTR(qemuBlockNodeNameBackingChainData) data = NULL;
     qemuBlockNodeNameBackingChainDataPtr backingdata = NULL;
     virJSONValuePtr backing = virJSONValueObjectGetObject(next, "backing");
     virJSONValuePtr parent = virJSONValueObjectGetObject(next, "parent");
@@ -189,7 +192,6 @@ qemuBlockNodeNameGetBackingChainBacking(virJSONValuePtr next,
     ret = 0;

  cleanup:
-    qemuBlockNodeNameBackingChainDataFree(data);
     return ret;
 }

@@ -201,7 +203,7 @@ qemuBlockNodeNameGetBackingChainDisk(size_t pos ATTRIBUTE_UNUSED,
 {
     struct qemuBlockNodeNameGetBackingChainData *data = opaque;
     const char *device = virJSONValueObjectGetString(item, "device");
-    qemuBlockNodeNameBackingChainDataPtr devicedata = NULL;
+    VIR_AUTOPTR(qemuBlockNodeNameBackingChainData) devicedata = NULL;
     int ret = -1;

     if (qemuBlockNodeNameGetBackingChainBacking(item, data->nodenamestable,
@@ -216,7 +218,6 @@ qemuBlockNodeNameGetBackingChainDisk(size_t pos ATTRIBUTE_UNUSED,
     ret = 1; /* we don't really want to steal @item */

  cleanup:
-    qemuBlockNodeNameBackingChainDataFree(devicedata);

     return ret;
 }
-- 
2.20.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[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