[Spice-devel] [spice-gtk v1 3/5] usb-device-manager: handling failure from GUdevClient

Victor Toso victortoso at redhat.com
Mon Nov 14 23:26:53 UTC 2016


From: Victor Toso <me at victortoso.com>

g_udev_client_new() can fail in more then one situation in its
initable_init() method.

Signed-off-by: Victor Toso <victortoso at redhat.com>
---
 src/usb-device-manager.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/usb-device-manager.c b/src/usb-device-manager.c
index 3d4bd98..ae73a02 100644
--- a/src/usb-device-manager.c
+++ b/src/usb-device-manager.c
@@ -321,6 +321,10 @@ static gboolean spice_usb_device_manager_initable_init(GInitable  *initable,
     /* Start listening for usb devices plug / unplug */
 #ifdef USE_GUDEV
     priv->udev = g_udev_client_new(subsystems, err);
+    if (priv->udev == NULL) {
+        g_warning("Error initializing GUdevClient");
+        return FALSE;
+    }
     g_signal_connect(G_OBJECT(priv->udev), "uevent",
                      G_CALLBACK(spice_usb_device_manager_uevent_cb), self);
     /* Do coldplug (detection of already connected devices) */
-- 
2.9.3



More information about the Spice-devel mailing list