summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Hjelm <hjelmn@google.com>2023-02-13 10:57:27 -0700
committerTormod Volden <debian.tormod@gmail.com>2023-03-12 12:36:43 +0100
commitd2da7f9b1d52e55142775497ca170d9001e72c16 (patch)
tree056281cba743b135f37ad4435852727be3249f44
parent2abb2a186e6c085396654851f7d18aa20ce2e753 (diff)
downloadlibusb-d2da7f9b1d52e55142775497ca170d9001e72c16.tar.gz
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 <hjelmn@google.com>
-rw-r--r--libusb/core.c12
-rw-r--r--libusb/version_nano.h2
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 <hjelmn@cs.unm.edu>
+ * Copyright © 2012-2023 Nathan Hjelm <hjelmn@cs.unm.edu>
* Copyright © 2007-2008 Daniel Drake <dsd@gentoo.org>
* Copyright © 2001 Johannes Erdfelt <johannes@erdfelt.com>
*
@@ -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