aboutsummaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2020-04-13 21:49:28 -0700
committerAaron Rossetto <aaron.rossetto@ni.com>2020-04-15 07:45:18 -0500
commit0597c128475385daf9d0abafc60ec861c951eeaa (patch)
treeb1fd490c083955a6020a8f0c257a86f67aa91335 /host
parentd90e8a91fd37e49dad36cf8fc890a08494d979c2 (diff)
downloaduhd-0597c128475385daf9d0abafc60ec861c951eeaa.tar.gz
uhd-0597c128475385daf9d0abafc60ec861c951eeaa.tar.bz2
uhd-0597c128475385daf9d0abafc60ec861c951eeaa.zip
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.
Diffstat (limited to 'host')
-rw-r--r--host/lib/transport/libusb1_base.cpp15
1 files changed, 14 insertions, 1 deletions
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<libusb_log_level>(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<libusb_log_level>(level));
+#else
libusb_set_debug(new_global_session->get_context(), level);
+#endif
+ }
}
return new_global_session;