Page MenuHomeFreeBSD

D21877.diff
No OneTemporary

D21877.diff

Index: head/lib/libusb/libusb10.c
===================================================================
--- head/lib/libusb/libusb10.c
+++ head/lib/libusb/libusb10.c
@@ -91,7 +91,8 @@
libusb_set_debug(libusb_context *ctx, int level)
{
ctx = GET_CONTEXT(ctx);
- if (ctx)
+ /* debug_fixed is set when the environment overrides libusb_set_debug */
+ if (ctx && ctx->debug_fixed == 0)
ctx->debug = level;
}
@@ -132,7 +133,7 @@
{
struct libusb_context *ctx;
pthread_condattr_t attr;
- char *debug;
+ char *debug, *ep;
int ret;
ctx = malloc(sizeof(*ctx));
@@ -143,9 +144,23 @@
debug = getenv("LIBUSB_DEBUG");
if (debug != NULL) {
- ctx->debug = atoi(debug);
- if (ctx->debug != 0)
+ /*
+ * If LIBUSB_DEBUG is set, we'll honor that and use it to
+ * override libusb_set_debug calls.
+ */
+ errno = 0;
+ ctx->debug = strtol(debug, &ep, 10);
+ if (errno == 0 && *ep == '\0') {
ctx->debug_fixed = 1;
+ } else {
+ /*
+ * LIBUSB_DEBUG conversion failed for some reason, but
+ * we don't care about the specifics all that much. We
+ * can't use it either way. Force it to the default,
+ * 0, in case we had a partial number.
+ */
+ ctx->debug = 0;
+ }
}
TAILQ_INIT(&ctx->pollfds);
TAILQ_INIT(&ctx->tr_done);

File Metadata

Mime Type
text/plain
Expires
Mon, Apr 20, 8:12 PM (14 h, 23 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31861906
Default Alt Text
D21877.diff (1 KB)

Event Timeline