summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Frederik Carlier2021-01-20 10:39:35 +0100
committerGravatar Frederik Carlier2021-01-20 10:39:35 +0100
commitb1a7c7ebf110aece7175b0c4d032608a00a7b55b (patch)
tree0d017369ccf31d220b177d0665b65584bc5d2564
parent1248a070f872e15a15b348150ff8bfb96491ddc3 (diff)
downloadusbmuxd-b1a7c7ebf110aece7175b0c4d032608a00a7b55b.tar.gz
usbmuxd-b1a7c7ebf110aece7175b0c4d032608a00a7b55b.tar.bz2
Don't call libusb_set_option if libusb_init fails
-rw-r--r--src/usb.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/usb.c b/src/usb.c
index e334707..abc4a2b 100644
--- a/src/usb.c
+++ b/src/usb.c
@@ -827,17 +827,17 @@ int usb_init(void)
device_polling = 1;
res = libusb_init(NULL);
+ if (res != 0) {
+ usbmuxd_log(LL_FATAL, "libusb_init failed: %s", libusb_error_name(res));
+ return -1;
+ }
+
#if LIBUSB_API_VERSION >= 0x01000106
libusb_set_option(NULL, LIBUSB_OPTION_LOG_LEVEL, (log_level >= LL_DEBUG ? LIBUSB_LOG_LEVEL_DEBUG: (log_level >= LL_WARNING ? LIBUSB_LOG_LEVEL_WARNING: LIBUSB_LOG_LEVEL_NONE)));
#else
libusb_set_debug(NULL, (log_level >= LL_DEBUG ? LIBUSB_LOG_LEVEL_DEBUG: (log_level >= LL_WARNING ? LIBUSB_LOG_LEVEL_WARNING: LIBUSB_LOG_LEVEL_NONE)));
#endif
- if(res != 0) {
- usbmuxd_log(LL_FATAL, "libusb_init failed: %s", libusb_error_name(res));
- return -1;
- }
-
collection_init(&device_list);
#ifdef HAVE_LIBUSB_HOTPLUG_API