summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2014-11-20 14:15:50 +0000
committerRichard Hughes <richard@hughsie.com>2014-11-20 14:15:54 +0000
commitc942b22a503c03bdb2c5377a41e5aa566c10a523 (patch)
treeb45d667051682eb713fbcf18867c4fbff6a51f8e
parenta404243608dbf4129bad0fda348fdb93792d650f (diff)
downloadgusb-c942b22a503c03bdb2c5377a41e5aa566c10a523.tar.gz
Always set a device platform ID
It appears applications go boom when they try to use the unset platform ID as a hash table lookup key...
-rw-r--r--gusb/gusb-device-list.c9
-rw-r--r--gusb/gusb-device.c2
2 files changed, 8 insertions, 3 deletions
diff --git a/gusb/gusb-device-list.c b/gusb/gusb-device-list.c
index c47a9a7..d35a66b 100644
--- a/gusb/gusb-device-list.c
+++ b/gusb/gusb-device-list.c
@@ -223,6 +223,7 @@ g_usb_device_list_add_device (GUsbDeviceList *list, struct libusb_device *dev)
{
GUsbDevice *device = NULL;
GUsbDeviceListPrivate *priv = list->priv;
+ gchar *platform_id = NULL;
guint8 bus;
guint8 address;
@@ -235,9 +236,12 @@ g_usb_device_list_add_device (GUsbDeviceList *list, struct libusb_device *dev)
g_debug ("%i:%i already exists", bus, address);
goto out;
}
- device = _g_usb_device_new (priv->context, dev, NULL);
+
+ /* add the device */
+ platform_id = g_strdup_printf ("usb[%02x:%02x]", bus, address);
+ device = _g_usb_device_new (priv->context, dev, platform_id);
if (g_usb_device_get_device_class (device) == 0x09) {
- g_debug ("%i:%i is a hub, ignoring", bus, address);
+ g_debug ("%02x:%02x is a hub, ignoring", bus, address);
goto out;
}
g_ptr_array_add (priv->devices, g_object_ref (device));
@@ -245,6 +249,7 @@ g_usb_device_list_add_device (GUsbDeviceList *list, struct libusb_device *dev)
out:
if (device != NULL)
g_object_unref (device);
+ g_free (platform_id);
}
/**
diff --git a/gusb/gusb-device.c b/gusb/gusb-device.c
index e7a804b..3a81491 100644
--- a/gusb/gusb-device.c
+++ b/gusb/gusb-device.c
@@ -1330,7 +1330,7 @@ _g_usb_device_get_device (GUsbDevice *device)
* Gets the platform identifier for the device.
* On Linux, this is the full sysfs path of the device
*
- * Return value: The platform ID, or %NULL
+ * Return value: The platform ID, e.g. "usb[03:03]"
*
* Since: 0.1.1
**/