diff options
author | Richard Hughes <richard@hughsie.com> | 2017-03-24 16:01:53 +0000 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2017-03-24 16:01:53 +0000 |
commit | 0320c7bbf98b81d9bf2a1c4d56f401749d5b7abd (patch) | |
tree | c0a148902519562a1381e4b4726115eecf9402ad | |
parent | fdd1393b2d682abe52508840a51a4b95443679d6 (diff) | |
download | gusb-0320c7bbf98b81d9bf2a1c4d56f401749d5b7abd.tar.gz |
Correctly detect removed devices when using g_usb_context_rescan()
-rw-r--r-- | gusb/gusb-context.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/gusb/gusb-context.c b/gusb/gusb-context.c index 4fb3100..fbd56d7 100644 --- a/gusb/gusb-context.c +++ b/gusb/gusb-context.c @@ -421,10 +421,11 @@ g_usb_context_rescan (GUsbContext *context) } /* look for any removed devices */ + libusb_get_device_list (priv->ctx, &dev_list); for (l = existing_devices; l != NULL; l = l->next) { device = G_USB_DEVICE (l->data); found = FALSE; - for (i = 0; dev_list && dev_list[i]; i++) { + for (i = 0; dev_list != NULL && dev_list[i] != NULL; i++) { if (libusb_get_bus_number (dev_list[i]) == g_usb_device_get_bus (device) && libusb_get_device_address (dev_list[i]) == g_usb_device_get_address (device)) { found = TRUE; @@ -438,8 +439,7 @@ g_usb_context_rescan (GUsbContext *context) } /* add any devices not yet added (duplicates will be filtered */ - libusb_get_device_list (priv->ctx, &dev_list); - for (i = 0; dev_list && dev_list[i]; i++) + for (i = 0; dev_list != NULL && dev_list[i] != NULL; i++) g_usb_context_add_device (context, dev_list[i]); g_list_free (existing_devices); |