From 565bb18011d72d4aec2b24c11bba27c783863930 Mon Sep 17 00:00:00 2001 From: Francis Hart Date: Mon, 17 Oct 2022 11:41:52 +0300 Subject: Fix setting log level before libusb_init() The header docs state its possible to set a default log level before calling libusb_init(), and that this log level will be used for all contexts created after (to quote): "Note that libusb_set_option(NULL, ...) is special, and adds an option to a list of default options for new contexts." This updates the logic inside libusb_init() to ensure this behaviour is followed. Fixes #1207 Signed-off-by: Francis Hart Signed-off-by: Nathan Hjelm --- libusb/core.c | 2 +- libusb/version_nano.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libusb/core.c b/libusb/core.c index 4f98ef9..634002b 100644 --- a/libusb/core.c +++ b/libusb/core.c @@ -2306,7 +2306,7 @@ int API_EXPORTED libusb_init(libusb_context **ctx) } #if defined(ENABLE_LOGGING) && !defined(ENABLE_DEBUG_LOGGING) - if (NULL == ctx && default_context_options[LIBUSB_OPTION_LOG_LEVEL].is_set) { + if (default_context_options[LIBUSB_OPTION_LOG_LEVEL].is_set) { _ctx->debug = default_context_options[LIBUSB_OPTION_LOG_LEVEL].arg.ival; } else { _ctx->debug = get_env_debug_level(); diff --git a/libusb/version_nano.h b/libusb/version_nano.h index dea5b36..aa4bdc0 100644 --- a/libusb/version_nano.h +++ b/libusb/version_nano.h @@ -1 +1 @@ -#define LIBUSB_NANO 11758 +#define LIBUSB_NANO 11759 -- cgit v1.2.1