Replace virStoragePoolFree with virObjectUnref

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.
This commit is contained in:
John Ferlan 2014-11-30 09:35:12 -05:00
parent d1219054e3
commit adbbff5fb7
5 changed files with 7 additions and 20 deletions

2
cfg.mk
View File

@ -992,7 +992,7 @@ sc_prohibit_system_error_with_vir_err:
# functions. There's a corresponding exclude to allow usage within tests, # functions. There's a corresponding exclude to allow usage within tests,
# docs, examples, tools, src/libvirt-*.c, and include/libvirt/libvirt-*.h # docs, examples, tools, src/libvirt-*.c, and include/libvirt/libvirt-*.h
sc_prohibit_virXXXFree: sc_prohibit_virXXXFree:
@prohibit='\bvir(Domain|Network|NodeDevice|StorageVol)Free\b' \ @prohibit='\bvir(Domain|Network|NodeDevice|StorageVol|StoragePool)Free\b' \
exclude='sc_prohibit_virXXXFree' \ exclude='sc_prohibit_virXXXFree' \
halt='avoid using 'virXXXFree', use 'virObjectUnref' instead' \ halt='avoid using 'virXXXFree', use 'virObjectUnref' instead' \
$(_sc_search_regexp) $(_sc_search_regexp)

View File

@ -4665,7 +4665,7 @@ remoteDispatchConnectListAllStoragePools(virNetServerPtr server ATTRIBUTE_UNUSED
virNetMessageSaveError(rerr); virNetMessageSaveError(rerr);
if (pools && npools > 0) { if (pools && npools > 0) {
for (i = 0; i < npools; i++) for (i = 0; i < npools; i++)
virStoragePoolFree(pools[i]); virObjectUnref(pools[i]);
VIR_FREE(pools); VIR_FREE(pools);
} }
return rv; return rv;
@ -4731,8 +4731,7 @@ remoteDispatchStoragePoolListAllVolumes(virNetServerPtr server ATTRIBUTE_UNUSED,
virObjectUnref(vols[i]); virObjectUnref(vols[i]);
VIR_FREE(vols); VIR_FREE(vols);
} }
if (pool) virObjectUnref(pool);
virStoragePoolFree(pool);
return rv; return rv;
} }

View File

@ -2523,10 +2523,8 @@ virStoragePoolObjListExport(virConnectPtr conn,
cleanup: cleanup:
if (tmp_pools) { if (tmp_pools) {
for (i = 0; i < npools; i++) { for (i = 0; i < npools; i++)
if (tmp_pools[i]) virObjectUnref(tmp_pools[i]);
virStoragePoolFree(tmp_pools[i]);
}
} }
VIR_FREE(tmp_pools); VIR_FREE(tmp_pools);

View File

@ -3682,8 +3682,7 @@ remoteConnectListAllStoragePools(virConnectPtr conn,
cleanup: cleanup:
if (tmp_pools) { if (tmp_pools) {
for (i = 0; i < ret.pools.pools_len; i++) for (i = 0; i < ret.pools.pools_len; i++)
if (tmp_pools[i]) virObjectUnref(tmp_pools[i]);
virStoragePoolFree(tmp_pools[i]);
VIR_FREE(tmp_pools); VIR_FREE(tmp_pools);
} }

View File

@ -3006,7 +3006,6 @@ virStorageTranslateDiskSourcePool(virConnectPtr conn,
char *poolxml = NULL; char *poolxml = NULL;
virStorageVolInfo info; virStorageVolInfo info;
int ret = -1; int ret = -1;
virErrorPtr savedError = NULL;
if (def->src->type != VIR_STORAGE_TYPE_VOLUME) if (def->src->type != VIR_STORAGE_TYPE_VOLUME)
return 0; return 0;
@ -3142,16 +3141,8 @@ virStorageTranslateDiskSourcePool(virConnectPtr conn,
ret = 0; ret = 0;
cleanup: cleanup:
if (ret < 0) virObjectUnref(pool);
savedError = virSaveLastError();
if (pool)
virStoragePoolFree(pool);
virObjectUnref(vol); virObjectUnref(vol);
if (savedError) {
virSetError(savedError);
virFreeError(savedError);
}
VIR_FREE(poolxml); VIR_FREE(poolxml);
virStoragePoolDefFree(pooldef); virStoragePoolDefFree(pooldef);
return ret; return ret;