[PATCH 10/11] Replace virInterfaceFree with virObjectUnref

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Since virInterfac3Free 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@xxxxxxxxxx>
---
 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 bc9310d..e8ff5f5 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 dc00424..3e4dc1f 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 1734329..116d84e 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 e9fd941..d4f8c0f 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 28bb46a..3dc3ecb 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);
 
-- 
1.9.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]