On 1/18/21 2:53 PM, Daniel Henrique Barboza wrote:
The function returns -1 on error, but no caller is actually checking
the return value. Making it 'void' makes more sense with its
current use.
Signed-off-by: Daniel Henrique Barboza <danielhb413(a)gmail.com>
NAK - you can't change a public function.
---
include/libvirt/libvirt-nodedev.h | 2 +-
src/libvirt-nodedev.c | 15 +++++++++++----
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/include/libvirt/libvirt-nodedev.h b/include/libvirt/libvirt-nodedev.h
index eab8abf6ab..5634980a75 100644
--- a/include/libvirt/libvirt-nodedev.h
+++ b/include/libvirt/libvirt-nodedev.h
@@ -114,7 +114,7 @@ char * virNodeDeviceGetXMLDesc (virNodeDevicePtr
dev,
unsigned int flags);
int virNodeDeviceRef (virNodeDevicePtr dev);
-int virNodeDeviceFree (virNodeDevicePtr dev);
+void virNodeDeviceFree (virNodeDevicePtr dev);
int virNodeDeviceDettach (virNodeDevicePtr dev);
int virNodeDeviceDetachFlags(virNodeDevicePtr dev,
diff --git a/src/libvirt-nodedev.c b/src/libvirt-nodedev.c
index eb8c735a8c..fcca40f47b 100644
--- a/src/libvirt-nodedev.c
+++ b/src/libvirt-nodedev.c
@@ -445,19 +445,26 @@ virNodeDeviceListCaps(virNodeDevicePtr dev,
* Drops a reference to the node device, freeing it if
* this was the last reference.
*
- * Returns the 0 for success, -1 for error.
+ * Throws a VIR_ERR_INVALID_NODE_DEVICE error if @dev is
+ * not a valid node device. Does nothing if @dev is
+ * NULL.
*/
-int
+void
virNodeDeviceFree(virNodeDevicePtr dev)
{
+ if (!dev)
+ return;
+
VIR_DEBUG("dev=%p, conn=%p", dev, dev ? dev->conn : NULL);
virResetLastError();
- virCheckNodeDeviceReturn(dev, -1);
+ virCheckNodeDeviceGoto(dev, invalid_device);
virObjectUnref(dev);
- return 0;
+
+ invalid_device:
+ return;
}