From 5a05636b84f3486f77c31b27e8fc095ee6cb96e8 Mon Sep 17 00:00:00 2001 From: Sylvain Fasel Date: Tue, 2 Jan 2024 23:46:42 +0100 Subject: [PATCH] =?UTF-8?q?=EF=BB=BFexample/hotplugtest:=20Ignore=20unavai?= =?UTF-8?q?lable=20devices?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- examples/hotplugtest.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/examples/hotplugtest.c b/examples/hotplugtest.c index 3e092cf45..8170e898a 100644 --- a/examples/hotplugtest.c +++ b/examples/hotplugtest.c @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #include #include @@ -51,7 +53,13 @@ static int LIBUSB_CALL hotplug_callback(libusb_context *ctx, libusb_device *dev, } rc = libusb_open (dev, &handle); - if (LIBUSB_SUCCESS != rc) { + if (LIBUSB_SUCCESS != rc + && LIBUSB_ERROR_ACCESS != rc +#if defined(PLATFORM_WINDOWS) + && LIBUSB_ERROR_NOT_SUPPORTED != rc + && LIBUSB_ERROR_NOT_FOUND != rc +#endif + ) { fprintf (stderr, "No access to device: %s\n", libusb_strerror((enum libusb_error)rc)); }