[PATCH 06/11] Replace virStoragePoolFree with virObjectUnref

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

 



Since virStoragePoolFree will call virObjectUnref anyway, let's just use that
directly so as to avoid the possibility that we inadvertently clear out
a pending error message when using the public API.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 cfg.mk                       |  2 +-
 daemon/remote.c              |  5 ++---
 src/conf/storage_conf.c      |  6 ++----
 src/remote/remote_driver.c   |  3 +--
 src/storage/storage_driver.c | 11 +----------
 5 files changed, 7 insertions(+), 20 deletions(-)

diff --git a/cfg.mk b/cfg.mk
index 5da7b22..4766f0b 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -992,7 +992,7 @@ sc_prohibit_system_error_with_vir_err:
 # functions. There's a corresponding exclude to allow usage within tests,
 # docs, examples, tools, src/libvirt-*.c, and include/libvirt/libvirt-*.h
 sc_prohibit_virXXXFree:
-	@prohibit='\bvir(Domain|Network|NodeDevice|StorageVol)Free\b'	\
+	@prohibit='\bvir(Domain|Network|NodeDevice|StorageVol|StoragePool)Free\b'	\
 	exclude='sc_prohibit_virXXXFree' \
 	halt='avoid using 'virXXXFree', use 'virObjectUnref' instead' \
 	  $(_sc_search_regexp)
diff --git a/daemon/remote.c b/daemon/remote.c
index 644f10e..fe1b13c 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -4665,7 +4665,7 @@ remoteDispatchConnectListAllStoragePools(virNetServerPtr server ATTRIBUTE_UNUSED
         virNetMessageSaveError(rerr);
     if (pools && npools > 0) {
         for (i = 0; i < npools; i++)
-            virStoragePoolFree(pools[i]);
+            virObjectUnref(pools[i]);
         VIR_FREE(pools);
     }
     return rv;
@@ -4731,8 +4731,7 @@ remoteDispatchStoragePoolListAllVolumes(virNetServerPtr server ATTRIBUTE_UNUSED,
             virObjectUnref(vols[i]);
         VIR_FREE(vols);
     }
-    if (pool)
-        virStoragePoolFree(pool);
+    virObjectUnref(pool);
     return rv;
 }
 
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index f75e862..3987470 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -2523,10 +2523,8 @@ virStoragePoolObjListExport(virConnectPtr conn,
 
  cleanup:
     if (tmp_pools) {
-        for (i = 0; i < npools; i++) {
-            if (tmp_pools[i])
-                virStoragePoolFree(tmp_pools[i]);
-        }
+        for (i = 0; i < npools; i++)
+            virObjectUnref(tmp_pools[i]);
     }
 
     VIR_FREE(tmp_pools);
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index b89984e..830e1d4 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -3682,8 +3682,7 @@ remoteConnectListAllStoragePools(virConnectPtr conn,
  cleanup:
     if (tmp_pools) {
         for (i = 0; i < ret.pools.pools_len; i++)
-            if (tmp_pools[i])
-                virStoragePoolFree(tmp_pools[i]);
+            virObjectUnref(tmp_pools[i]);
         VIR_FREE(tmp_pools);
     }
 
diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index 0fcbc4e..99ccb49 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -3006,7 +3006,6 @@ virStorageTranslateDiskSourcePool(virConnectPtr conn,
     char *poolxml = NULL;
     virStorageVolInfo info;
     int ret = -1;
-    virErrorPtr savedError = NULL;
 
     if (def->src->type != VIR_STORAGE_TYPE_VOLUME)
         return 0;
@@ -3142,16 +3141,8 @@ virStorageTranslateDiskSourcePool(virConnectPtr conn,
 
     ret = 0;
  cleanup:
-    if (ret < 0)
-        savedError = virSaveLastError();
-    if (pool)
-        virStoragePoolFree(pool);
+    virObjectUnref(pool);
     virObjectUnref(vol);
-    if (savedError) {
-        virSetError(savedError);
-        virFreeError(savedError);
-    }
-
     VIR_FREE(poolxml);
     virStoragePoolDefFree(pooldef);
     return ret;
-- 
1.9.3

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