[PATCH 2/7] Introduce virStoragePoolSourceDeviceClear

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

 



Open-coding one VIR_FREE in the test suite just doesn't seem right.
---
 src/conf/storage_conf.c  | 13 +++++++++----
 src/conf/storage_conf.h  |  1 +
 src/libvirt_private.syms |  1 +
 3 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index ac323d0..9c2962f 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -357,6 +357,13 @@ virStoragePoolSourceAdapterClear(virStoragePoolSourceAdapter adapter)
 }
 
 void
+virStoragePoolSourceDeviceClear(virStoragePoolSourceDevicePtr dev)
+{
+    VIR_FREE(dev->freeExtents);
+    VIR_FREE(dev->path);
+}
+
+void
 virStoragePoolSourceClear(virStoragePoolSourcePtr source)
 {
     size_t i;
@@ -369,10 +376,8 @@ virStoragePoolSourceClear(virStoragePoolSourcePtr source)
     }
     VIR_FREE(source->hosts);
 
-    for (i = 0; i < source->ndevice; i++) {
-        VIR_FREE(source->devices[i].freeExtents);
-        VIR_FREE(source->devices[i].path);
-    }
+    for (i = 0; i < source->ndevice; i++)
+        virStoragePoolSourceDeviceClear(&source->devices[i]);
     VIR_FREE(source->devices);
     VIR_FREE(source->dir);
     VIR_FREE(source->name);
diff --git a/src/conf/storage_conf.h b/src/conf/storage_conf.h
index 251b968..636c9aa 100644
--- a/src/conf/storage_conf.h
+++ b/src/conf/storage_conf.h
@@ -432,6 +432,7 @@ int virStoragePoolObjDeleteDef(virStoragePoolObjPtr pool);
 
 void virStorageVolDefFree(virStorageVolDefPtr def);
 void virStoragePoolSourceClear(virStoragePoolSourcePtr source);
+void virStoragePoolSourceDeviceClear(virStoragePoolSourceDevicePtr dev);
 void virStoragePoolSourceFree(virStoragePoolSourcePtr source);
 void virStoragePoolDefFree(virStoragePoolDefPtr def);
 void virStoragePoolObjFree(virStoragePoolObjPtr pool);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index f1607cd..ea16cf5 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -710,6 +710,7 @@ virStoragePoolObjUnlock;
 virStoragePoolSourceAdapterTypeTypeFromString;
 virStoragePoolSourceAdapterTypeTypeToString;
 virStoragePoolSourceClear;
+virStoragePoolSourceDeviceClear;
 virStoragePoolSourceFindDuplicate;
 virStoragePoolSourceFindDuplicateDevices;
 virStoragePoolSourceFree;
-- 
1.8.3.2

--
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]