aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Kanis <lars.kanis@sincnovation.com>2023-12-21 12:37:51 +0100
committerTormod Volden <debian.tormod@gmail.com>2024-01-27 10:52:12 +0100
commita5483bc0f735291eec23b65a76bb7f0fac90e6a8 (patch)
treed3ac1317b4da14de964bbb445f0cc2b43b194367
parentd09d341f411c94bb2835e9085122dff794716540 (diff)
downloadlibusb-a5483bc0f735291eec23b65a76bb7f0fac90e6a8.tar.gz
core: Allow setting global log callback after first libusb_init()
When setting LIBUSB_OPTION_LOG_CB before the first libusb_init(), the global callback is set. However, after the first libusb_init() there is a default context, and setting LIBUSB_OPTION_LOG_CB would only set this default context, and not the global callback. There would be no way to set the global callback through libusb_set_option(). Change this so that the global log callback is set in addition to the default context (when libusb_set_option is called with NULL context). Closes #1397
-rw-r--r--libusb/core.c6
-rw-r--r--libusb/version_nano.h2
2 files changed, 3 insertions, 5 deletions
diff --git a/libusb/core.c b/libusb/core.c
index d2605fe..e28e77f 100644
--- a/libusb/core.c
+++ b/libusb/core.c
@@ -2327,16 +2327,14 @@ int API_EXPORTEDV libusb_set_option(libusb_context *ctx,
default_context_options[option].arg.ival = arg;
} else if (LIBUSB_OPTION_LOG_CB == option) {
default_context_options[option].arg.log_cbval = log_cb;
+ libusb_set_log_cb_internal(NULL, log_cb, LIBUSB_LOG_CB_GLOBAL);
}
usbi_mutex_static_unlock(&default_context_lock);
}
ctx = usbi_get_context(ctx);
- if (NULL == ctx) {
- if (LIBUSB_OPTION_LOG_CB == option)
- libusb_set_log_cb_internal(NULL, log_cb, LIBUSB_LOG_CB_GLOBAL);
+ if (NULL == ctx)
break;
- }
switch (option) {
case LIBUSB_OPTION_LOG_LEVEL:
diff --git a/libusb/version_nano.h b/libusb/version_nano.h
index 8e2f060..60baa17 100644
--- a/libusb/version_nano.h
+++ b/libusb/version_nano.h
@@ -1 +1 @@
-#define LIBUSB_NANO 11875
+#define LIBUSB_NANO 11876