From 91a7c4bdf2633029ecde85718501b6c7a7d95e9d Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Wed, 8 Jun 2022 11:58:08 -0700 Subject: [PATCH] LibusbUtils: Log warnings when libusb_set_option or libusb_handle_events_timeout_completed fail --- Source/Core/Core/LibusbUtils.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Source/Core/Core/LibusbUtils.cpp b/Source/Core/Core/LibusbUtils.cpp index dadad60a2d..b905219207 100644 --- a/Source/Core/Core/LibusbUtils.cpp +++ b/Source/Core/Core/LibusbUtils.cpp @@ -28,7 +28,9 @@ public: return; #ifdef _WIN32 - libusb_set_option(m_context, LIBUSB_OPTION_USE_USBDK); + const int usbdk_ret = libusb_set_option(m_context, LIBUSB_OPTION_USE_USBDK); + if (usbdk_ret != LIBUSB_SUCCESS && usbdk_ret != LIBUSB_ERROR_NOT_FOUND) + WARN_LOG_FMT(IOS_USB, "Failed to set LIBUSB_OPTION_USE_USBDK: {}", ErrorWrap(usbdk_ret)); #endif m_event_thread_running.Set(); m_event_thread = std::thread(&Impl::EventThread, this); @@ -71,7 +73,11 @@ private: Common::SetCurrentThreadName("libusb thread"); timeval tv{5, 0}; while (m_event_thread_running.IsSet()) - libusb_handle_events_timeout_completed(m_context, &tv, nullptr); + { + const int ret = libusb_handle_events_timeout_completed(m_context, &tv, nullptr); + if (ret != LIBUSB_SUCCESS) + WARN_LOG_FMT(IOS_USB, "libusb_handle_events_timeout_completed failed: {}", ErrorWrap(ret)); + } } libusb_context* m_context = nullptr;