[gvfs] gphoto2: Ignore devices without a device file



commit 97629179dba1205b512d1e82b9b9fed68a7b30d4
Author: Bastien Nocera <hadess hadess net>
Date:   Thu Mar 1 11:06:59 2018 +0100

    gphoto2: Ignore devices without a device file
    
    If there's no device file, which means libusb won't be able to open the
    device, no need to print a warning, simply ignore the device.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=793925

 monitor/gphoto2/ggphoto2volumemonitor.c |   28 +++++++++++++++++++---------
 1 files changed, 19 insertions(+), 9 deletions(-)
---
diff --git a/monitor/gphoto2/ggphoto2volumemonitor.c b/monitor/gphoto2/ggphoto2volumemonitor.c
index 0d141cd..a9f51de 100644
--- a/monitor/gphoto2/ggphoto2volumemonitor.c
+++ b/monitor/gphoto2/ggphoto2volumemonitor.c
@@ -139,7 +139,15 @@ gudev_add_camera (GGPhoto2VolumeMonitor *monitor, GUdevDevice *device, gboolean
     GGPhoto2Volume *volume;
     GList *store_heads, *l;
     guint num_store_heads;
-    const char *usb_bus_num, *usb_device_num;
+    const char *usb_bus_num, *usb_device_num, *device_path;
+
+    device_path = g_udev_device_get_device_file (device);
+    if (!device_path)
+      {
+        g_debug ("Ignoring device '%s' without a device file",
+                 g_udev_device_get_sysfs_path (device));
+        return;
+      }
 
 #ifdef HAVE_LIBMTP
     if (g_udev_device_get_property_as_boolean (device, "ID_MTP_DEVICE"))
@@ -150,16 +158,18 @@ gudev_add_camera (GGPhoto2VolumeMonitor *monitor, GUdevDevice *device, gboolean
 #endif /* HAVE_LIBMTP */
 
     usb_bus_num = g_udev_device_get_property (device, "BUSNUM");
-    if (usb_bus_num == NULL) {
-       g_warning("device %s has no BUSNUM property, ignoring", g_udev_device_get_device_file (device));
-       return;
-    }
+    if (usb_bus_num == NULL)
+      {
+        g_warning ("device %s has no BUSNUM property, ignoring", device_path);
+        return;
+      }
 
     usb_device_num = g_udev_device_get_property (device, "DEVNUM");
-    if (usb_device_num == NULL) {
-       g_warning("device %s has no DEVNUM property, ignoring", g_udev_device_get_device_file (device));
-       return;
-    }
+    if (usb_device_num == NULL)
+      {
+        g_warning ("device %s has no DEVNUM property, ignoring", device_path);
+        return;
+      }
 
     g_debug ("gudev_add_camera: camera device %s (bus: %s, device: %s)",
              g_udev_device_get_device_file (device),


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