]> xenbits.xensource.com Git - libvirt.git/commitdiff
Replace virStoragePoolFree with virObjectUnref
authorJohn Ferlan <jferlan@redhat.com>
Sun, 30 Nov 2014 14:35:12 +0000 (09:35 -0500)
committerJohn Ferlan <jferlan@redhat.com>
Tue, 2 Dec 2014 16:03:40 +0000 (11:03 -0500)
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.

cfg.mk
daemon/remote.c
src/conf/storage_conf.c
src/remote/remote_driver.c
src/storage/storage_driver.c

diff --git a/cfg.mk b/cfg.mk
index 5da7b22bf2f9d1df4a3f5c244db4c5225d39e00f..4766f0bf461881870262fafb120a43a3b8938535 100644 (file)
--- 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)
index 644f10e7d6ff248ce02ab3dfa9bea591b7d380fb..fe1b13c386bb9977761a084c35b46ef7208e6322 100644 (file)
@@ -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;
 }
 
index f75e862e0d7d550eeb5c987befab9564a1d51e0f..3987470450fe9517ccd51847c67f3b3f6bab1f04 100644 (file)
@@ -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);
index b89984ea7b65738b7016f57076510effee7cc1cd..830e1d475711cbca2c36a4219cc0ee309c1a046e 100644 (file)
@@ -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);
     }
 
index 0fcbc4ed6acbdf8f4d91a27d247983301ae0dfac..99ccb49ce0467b5bf54a19dab317af623e0551a0 100644 (file)
@@ -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;