From c56a591a849be41f9e7966c7e97973ffdc6940e9 Mon Sep 17 00:00:00 2001 From: John Ferlan Date: Sun, 30 Nov 2014 12:07:19 -0500 Subject: [PATCH] Replace virInterfaceFree with virObjectUnref Since virInterfaceFree 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 | 4 ++-- daemon/remote.c | 2 +- src/interface/interface_backend_netcf.c | 6 ++---- src/interface/interface_backend_udev.c | 2 +- src/remote/remote_driver.c | 3 +-- 5 files changed, 7 insertions(+), 10 deletions(-) diff --git a/cfg.mk b/cfg.mk index bc9310d28e..e8ff5f5cec 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|StoragePool|Stream|Secret|NWFilter)Free\b' \ + @prohibit='\bvir(Domain|Network|NodeDevice|StorageVol|StoragePool|Stream|Secret|NWFilter|Interface)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/test/test_driver.c|src/libvirt_public.syms|include/libvirt/libvirt-(domain|network|nodedev|storage|stream|secret|nwfilter).h|src/libvirt-(domain|qemu|network|nodedev|storage|stream|secret|nwfilter).c$$) + ^(docs/|tests/|examples/|tools/|cfg.mk|src/test/test_driver.c|src/libvirt_public.syms|include/libvirt/libvirt-(domain|network|nodedev|storage|stream|secret|nwfilter|interface).h|src/libvirt-(domain|qemu|network|nodedev|storage|stream|secret|nwfilter|interface).c$$) diff --git a/daemon/remote.c b/daemon/remote.c index dc004243ba..3e4dc1ff35 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -4846,7 +4846,7 @@ remoteDispatchConnectListAllInterfaces(virNetServerPtr server ATTRIBUTE_UNUSED, virNetMessageSaveError(rerr); if (ifaces && nifaces > 0) { for (i = 0; i < nifaces; i++) - virInterfaceFree(ifaces[i]); + virObjectUnref(ifaces[i]); VIR_FREE(ifaces); } return rv; diff --git a/src/interface/interface_backend_netcf.c b/src/interface/interface_backend_netcf.c index 1734329128..116d84e210 100644 --- a/src/interface/interface_backend_netcf.c +++ b/src/interface/interface_backend_netcf.c @@ -675,10 +675,8 @@ netcfConnectListAllInterfaces(virConnectPtr conn, VIR_FREE(names); if (tmp_iface_objs) { - for (i = 0; i < niface_objs; i++) { - if (tmp_iface_objs[i]) - virInterfaceFree(tmp_iface_objs[i]); - } + for (i = 0; i < niface_objs; i++) + virObjectUnref(tmp_iface_objs[i]); VIR_FREE(tmp_iface_objs); } diff --git a/src/interface/interface_backend_udev.c b/src/interface/interface_backend_udev.c index e9fd9414f4..d4f8c0f56b 100644 --- a/src/interface/interface_backend_udev.c +++ b/src/interface/interface_backend_udev.c @@ -471,7 +471,7 @@ udevConnectListAllInterfaces(virConnectPtr conn, if (ifaces) { for (tmp_count = 0; tmp_count < count; tmp_count++) - virInterfaceFree(ifaces_list[tmp_count]); + virObjectUnref(ifaces_list[tmp_count]); } VIR_FREE(ifaces_list); diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 28bb46a3a2..3dc3ecbb76 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -3321,8 +3321,7 @@ remoteConnectListAllInterfaces(virConnectPtr conn, cleanup: if (tmp_ifaces) { for (i = 0; i < ret.ifaces.ifaces_len; i++) - if (tmp_ifaces[i]) - virInterfaceFree(tmp_ifaces[i]); + virObjectUnref(tmp_ifaces[i]); } VIR_FREE(tmp_ifaces); -- GitLab