[libvirt] [PATCH 05/11] Replace virStorageVolFree with virObjectUnref

John Ferlan jferlan at redhat.com
Mon Dec 1 15:56:19 UTC 2014


Since virStorageVolFree 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 at redhat.com>
---
 cfg.mk                       | 4 ++--
 daemon/remote.c              | 2 +-
 src/remote/remote_driver.c   | 3 +--
 src/storage/storage_driver.c | 9 +++------
 4 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/cfg.mk b/cfg.mk
index 97e573b..5da7b22 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)Free\b'	\
+	@prohibit='\bvir(Domain|Network|NodeDevice|StorageVol)Free\b'	\
 	exclude='sc_prohibit_virXXXFree' \
 	halt='avoid using 'virXXXFree', use 'virObjectUnref' instead' \
 	  $(_sc_search_regexp)
@@ -1186,4 +1186,4 @@ exclude_file_name_regexp--sc_prohibit_devname = \
   ^(tools/virsh.pod|cfg.mk|docs/.*)$$
 
 exclude_file_name_regexp--sc_prohibit_virXXXFree = \
-  ^(docs/|tests/|examples/|tools/|cfg.mk|src/libvirt_public.syms|include/libvirt/libvirt-(domain|network|nodedev).h|src/libvirt-(domain|qemu|network|nodedev).c$$)
+  ^(docs/|tests/|examples/|tools/|cfg.mk|src/test/test_driver.c|src/libvirt_public.syms|include/libvirt/libvirt-(domain|network|nodedev|storage).h|src/libvirt-(domain|qemu|network|nodedev|storage).c$$)
diff --git a/daemon/remote.c b/daemon/remote.c
index cfda8d8..644f10e 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -4728,7 +4728,7 @@ remoteDispatchStoragePoolListAllVolumes(virNetServerPtr server ATTRIBUTE_UNUSED,
         virNetMessageSaveError(rerr);
     if (vols && nvols > 0) {
         for (i = 0; i < nvols; i++)
-            virStorageVolFree(vols[i]);
+            virObjectUnref(vols[i]);
         VIR_FREE(vols);
     }
     if (pool)
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index d03b159..b89984e 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -3749,8 +3749,7 @@ remoteStoragePoolListAllVolumes(virStoragePoolPtr pool,
  cleanup:
     if (tmp_vols) {
         for (i = 0; i < ret.vols.vols_len; i++)
-            if (tmp_vols[i])
-                virStorageVolFree(tmp_vols[i]);
+            virObjectUnref(tmp_vols[i]);
         VIR_FREE(tmp_vols);
     }
 
diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index 88dea34..0fcbc4e 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -1282,10 +1282,8 @@ storagePoolListAllVolumes(virStoragePoolPtr pool,
 
  cleanup:
     if (tmp_vols) {
-        for (i = 0; i < nvols; i++) {
-            if (tmp_vols[i])
-                virStorageVolFree(tmp_vols[i]);
-        }
+        for (i = 0; i < nvols; i++)
+            virObjectUnref(tmp_vols[i]);
         VIR_FREE(tmp_vols);
     }
 
@@ -3148,8 +3146,7 @@ virStorageTranslateDiskSourcePool(virConnectPtr conn,
         savedError = virSaveLastError();
     if (pool)
         virStoragePoolFree(pool);
-    if (vol)
-        virStorageVolFree(vol);
+    virObjectUnref(vol);
     if (savedError) {
         virSetError(savedError);
         virFreeError(savedError);
-- 
1.9.3




More information about the libvir-list mailing list