[libvirt] [PATCH 23/23] Make usbFreeDevice accept a NULL device

Daniel P. Berrange berrange at redhat.com
Fri Nov 30 20:26:37 UTC 2012


From: "Daniel P. Berrange" <berrange at redhat.com>

Common practice is to accept NULL for all "free" methods

Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
---
 src/util/hostusb.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/util/hostusb.c b/src/util/hostusb.c
index 24f925b..79b04eb 100644
--- a/src/util/hostusb.c
+++ b/src/util/hostusb.c
@@ -355,6 +355,9 @@ usbGetDevice(unsigned int bus,
 void
 usbFreeDevice(usbDevice *dev)
 {
+    if (!dev)
+        return;
+
     VIR_DEBUG("%s %s: freeing", dev->id, dev->name);
     VIR_FREE(dev->path);
     VIR_FREE(dev);
-- 
1.8.0.1




More information about the libvir-list mailing list