Since virNodeDeviceFree 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(a)redhat.com>
---
cfg.mk | 4 ++--
daemon/remote.c | 5 ++---
src/conf/node_device_conf.c | 6 ++----
src/remote/remote_driver.c | 3 +--
4 files changed, 7 insertions(+), 11 deletions(-)
diff --git a/cfg.mk b/cfg.mk
index b5f853b..97e573b 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)Free\b' \
+ @prohibit='\bvir(Domain|Network|NodeDevice)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).h|src/libvirt-(domain|qemu|network).c$$)
+
^(docs/|tests/|examples/|tools/|cfg.mk|src/libvirt_public.syms|include/libvirt/libvirt-(domain|network|nodedev).h|src/libvirt-(domain|qemu|network|nodedev).c$$)
diff --git a/daemon/remote.c b/daemon/remote.c
index edae335..cfda8d8 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -3375,8 +3375,7 @@ remoteDispatchNodeDeviceGetParent(virNetServerPtr server
ATTRIBUTE_UNUSED,
cleanup:
if (rv < 0)
virNetMessageSaveError(rerr);
- if (dev)
- virNodeDeviceFree(dev);
+ virObjectUnref(dev);
return rv;
}
@@ -4908,7 +4907,7 @@ remoteDispatchConnectListAllNodeDevices(virNetServerPtr server
ATTRIBUTE_UNUSED,
virNetMessageSaveError(rerr);
if (devices && ndevices > 0) {
for (i = 0; i < ndevices; i++)
- virNodeDeviceFree(devices[i]);
+ virObjectUnref(devices[i]);
VIR_FREE(devices);
}
return rv;
diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
index 2a609e4..03b88a2 100644
--- a/src/conf/node_device_conf.c
+++ b/src/conf/node_device_conf.c
@@ -1825,10 +1825,8 @@ virNodeDeviceObjListExport(virConnectPtr conn,
cleanup:
if (tmp_devices) {
- for (i = 0; i < ndevices; i++) {
- if (tmp_devices[i])
- virNodeDeviceFree(tmp_devices[i]);
- }
+ for (i = 0; i < ndevices; i++)
+ virObjectUnref(tmp_devices[i]);
}
VIR_FREE(tmp_devices);
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index c23a087..d03b159 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -3387,8 +3387,7 @@ remoteConnectListAllNodeDevices(virConnectPtr conn,
cleanup:
if (tmp_devices) {
for (i = 0; i < ret.devices.devices_len; i++)
- if (tmp_devices[i])
- virNodeDeviceFree(tmp_devices[i]);
+ virObjectUnref(tmp_devices[i]);
VIR_FREE(tmp_devices);
}
--
1.9.3