From d2da7f9b1d52e55142775497ca170d9001e72c16 Mon Sep 17 00:00:00 2001 From: Nathan Hjelm Date: Mon, 13 Feb 2023 10:57:27 -0700 Subject: libusb_set_options: Adjust semantics of libusb_set_option for log level This commit updates the actual semantics of: libusb_set_option(_, LIBUSB_OPTION_LOG_LEVEL, _) to match the documentation. The documentation states that if the LIBUSB_DEBUG environment variable is set then that level overrides the value set by libusb_set_option. Signed-off-by: Nathan Hjelm --- libusb/core.c | 12 ++++++------ libusb/version_nano.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/libusb/core.c b/libusb/core.c index e374621..17e6117 100644 --- a/libusb/core.c +++ b/libusb/core.c @@ -1,7 +1,7 @@ /* -*- Mode: C; indent-tabs-mode:t ; c-basic-offset:8 -*- */ /* * Core functions for libusb - * Copyright © 2012-2021 Nathan Hjelm + * Copyright © 2012-2023 Nathan Hjelm * Copyright © 2007-2008 Daniel Drake * Copyright © 2001 Johannes Erdfelt * @@ -2432,14 +2432,14 @@ int API_EXPORTED libusb_init_context(libusb_context **ctx, const struct libusb_i return LIBUSB_ERROR_NO_MEM; } + _ctx->debug = LIBUSB_LOG_LEVEL_NONE; #if defined(ENABLE_LOGGING) && !defined(ENABLE_DEBUG_LOGGING) - if (default_context_options[LIBUSB_OPTION_LOG_LEVEL].is_set) { - _ctx->debug = default_context_options[LIBUSB_OPTION_LOG_LEVEL].arg.ival; - } else { + if (getenv("LIBUSB_DEBUG")) { _ctx->debug = get_env_debug_level(); - } - if (_ctx->debug != LIBUSB_LOG_LEVEL_NONE) _ctx->debug_fixed = 1; + } else if (default_context_options[LIBUSB_OPTION_LOG_LEVEL].is_set) { + _ctx->debug = default_context_options[LIBUSB_OPTION_LOG_LEVEL].arg.ival; + } #endif usbi_mutex_init(&_ctx->usb_devs_lock); diff --git a/libusb/version_nano.h b/libusb/version_nano.h index e443da4..12e1f7b 100644 --- a/libusb/version_nano.h +++ b/libusb/version_nano.h @@ -1 +1 @@ -#define LIBUSB_NANO 11784 +#define LIBUSB_NANO 11785 -- cgit v1.2.1