From 0597c128475385daf9d0abafc60ec861c951eeaa Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Mon, 13 Apr 2020 21:49:28 -0700 Subject: libusb: Remove deprecation warnings for libusb_set_debug Starting with 1.0.22, libusb considers libusb_set_debug() deprecated. This replaces said call with libusb_set_option(), conditionally on the libusb version. This has no effect on the execution, but will remove some compiler versions, and make this code more future-proof. Note that Ubuntu 18.04 ships libusb 1.0.21, so this conditional code needs to remain until that version is deprecated and libusb version is bumped higher. --- host/lib/transport/libusb1_base.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'host/lib/transport/libusb1_base.cpp') diff --git a/host/lib/transport/libusb1_base.cpp b/host/lib/transport/libusb1_base.cpp index 60481bc6a..9230a7e1f 100644 --- a/host/lib/transport/libusb1_base.cpp +++ b/host/lib/transport/libusb1_base.cpp @@ -35,7 +35,13 @@ public: libusb_session_impl(void) { UHD_ASSERT_THROW(libusb_init(&_context) == 0); +#if LIBUSB_API_VERSION >= 0x01000106 + libusb_set_option(_context, + LIBUSB_OPTION_LOG_LEVEL, + static_cast(debug_level)); +#else libusb_set_debug(_context, debug_level); +#endif task_handler = task::make( std::bind(&libusb_session_impl::libusb_event_handler_task, this, _context)); } @@ -104,8 +110,15 @@ libusb::session::sptr libusb::session::get_global_session(void) const char* level_string = getenv("LIBUSB_DEBUG_LEVEL"); if (level_string != NULL) { const int level = int(level_string[0] - '0'); // easy conversion to integer - if (level >= 0 and level <= 3) + if (level >= 0 and level <= 3) { +#if LIBUSB_API_VERSION >= 0x01000106 + libusb_set_option(new_global_session->get_context(), + LIBUSB_OPTION_LOG_LEVEL, + static_cast(level)); +#else libusb_set_debug(new_global_session->get_context(), level); +#endif + } } return new_global_session; -- cgit v1.2.3