Replace virStorageVolFree with virObjectUnref

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.
This commit is contained in:
John Ferlan 2014-11-30 09:26:02 -05:00
parent e3b456de0f
commit d1219054e3
4 changed files with 7 additions and 11 deletions

4
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,
# 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$$)

View File

@ -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)

View File

@ -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);
}

View File

@ -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);