summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2018-03-01 11:06:59 +0100
committerBastien Nocera <hadess@hadess.net>2018-03-01 17:33:22 +0100
commit97629179dba1205b512d1e82b9b9fed68a7b30d4 (patch)
tree6424118ae3b83a42edbc588085f647472c7042f4
parent5c91488cbaf750cd41e0314aed0c57a7416e5074 (diff)
downloadgvfs-97629179dba1205b512d1e82b9b9fed68a7b30d4.tar.gz
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
-rw-r--r--monitor/gphoto2/ggphoto2volumemonitor.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/monitor/gphoto2/ggphoto2volumemonitor.c b/monitor/gphoto2/ggphoto2volumemonitor.c
index 0d141cdb..a9f51de0 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),