Skip to content

Commit a790a6d

Browse files
authored
example/hotplugtest: Ignore unavailable devices (libusb#1425)
Depending on the devices or drivers, open() may return LIBUSB_ERROR_ACCESS LIBUSB_ERROR_NOT_FOUND LIBUSB_ERROR_NOT_SUPPORTED for devices "out of reach" to libusb.
1 parent 4799c20 commit a790a6d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

examples/hotplugtest.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,12 @@ static int LIBUSB_CALL hotplug_callback(libusb_context *ctx, libusb_device *dev,
5353
libusb_close (handle);
5454
}
5555
handle = new_handle;
56-
} else {
56+
} else if (LIBUSB_ERROR_ACCESS != rc
57+
#if defined(PLATFORM_WINDOWS)
58+
&& LIBUSB_ERROR_NOT_SUPPORTED != rc
59+
&& LIBUSB_ERROR_NOT_FOUND != rc
60+
#endif
61+
) {
5762
fprintf (stderr, "No access to device: %s\n",
5863
libusb_strerror((enum libusb_error)rc));
5964
}

0 commit comments

Comments
 (0)