Skip to content

Commit 544385c

Browse files
committed
Squashed 'libusb/' changes from c5aec6b..6bf2db6
6bf2db6 netbsd: Add error number to debug output cfc6694 netbsd: Print control transfer request debug values in hex 9891cf2 netbsd/openbsd: Remove extraneous parentheses around ioctl call 0a29e4f netbsd/openbsd: Drop parentheses around return values 681a851 sunos: Return error if OS paths hit their limits 7218b0d sunos: Fix error detection in sunos_submit_transfer() ba83b68 core: Fix always-true condition in log callback function setting 76df571 core: Avoid crash due to premature va_end 8450cc9 Revert "windows: Fix off-by-one error in HID backend for devices without report IDs" cc498de windows: Refactor parsing of MI_XX string taking into account it's 16-based 07441f5 Fix github action warnings a8a70f6 Fix build errors of tests with --enable-debug-log 3bace66 Fix build error with --enable-debug-log 7c169b8 Add github action build for --enable-debug-log git-subtree-dir: libusb git-subtree-split: 6bf2db6
1 parent 80190c5 commit 544385c

File tree

13 files changed

+163
-129
lines changed

13 files changed

+163
-129
lines changed

.github/workflows/linux.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
steps:
1616
# Checks-out your repository under $GITHUB_WORKSPACE, so your job
1717
# can access it
18-
- uses: actions/checkout@v2
18+
- uses: actions/checkout@v3
1919

2020
- name: setup prerequisites
2121
shell: bash
@@ -35,5 +35,9 @@ jobs:
3535
shell: bash
3636
run: .private/ci-build.sh --build-dir build-udev -- --enable-udev
3737

38+
- name: debug-log
39+
shell: bash
40+
run: .private/ci-build.sh --build-dir build-debug -- --enable-debug-log
41+
3842
- name: umockdev test
3943
run: .private/ci-container-build.sh docker.io/amd64/ubuntu:rolling

.github/workflows/macos.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
steps:
1616
# Checks-out your repository under $GITHUB_WORKSPACE, so your job
1717
# can access it
18-
- uses: actions/checkout@v2
18+
- uses: actions/checkout@v3
1919

2020
- name: setup prerequisites
2121
shell: bash

.github/workflows/msys2.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
run:
99
shell: msys2 {0}
1010
steps:
11-
- uses: actions/checkout@v2
11+
- uses: actions/checkout@v3
1212
- uses: msys2/setup-msys2@v2
1313
with:
1414
msystem: MINGW64

.github/workflows/msys2_clang32.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
run:
99
shell: msys2 {0}
1010
steps:
11-
- uses: actions/checkout@v2
11+
- uses: actions/checkout@v3
1212
- uses: msys2/setup-msys2@v2
1313
with:
1414
msystem: clang32

.github/workflows/msys2_clang64.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
run:
99
shell: msys2 {0}
1010
steps:
11-
- uses: actions/checkout@v2
11+
- uses: actions/checkout@v3
1212
- uses: msys2/setup-msys2@v2
1313
with:
1414
msystem: clang64

libusb/core.c

Lines changed: 49 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2302,6 +2302,7 @@ int API_EXPORTEDV libusb_set_option(libusb_context *ctx,
23022302
va_list ap;
23032303

23042304
va_start(ap, option);
2305+
23052306
if (LIBUSB_OPTION_LOG_LEVEL == option) {
23062307
arg = va_arg(ap, int);
23072308
if (arg < LIBUSB_LOG_LEVEL_NONE || arg > LIBUSB_LOG_LEVEL_DEBUG) {
@@ -2311,59 +2312,65 @@ int API_EXPORTEDV libusb_set_option(libusb_context *ctx,
23112312
if (LIBUSB_OPTION_LOG_CB == option) {
23122313
log_cb = (libusb_log_cb) va_arg(ap, libusb_log_cb);
23132314
}
2314-
va_end(ap);
23152315

2316-
if (LIBUSB_SUCCESS != r) {
2317-
return r;
2318-
}
2316+
do {
2317+
if (LIBUSB_SUCCESS != r) {
2318+
break;
2319+
}
23192320

2320-
if (option >= LIBUSB_OPTION_MAX) {
2321-
return LIBUSB_ERROR_INVALID_PARAM;
2322-
}
2321+
if (option >= LIBUSB_OPTION_MAX) {
2322+
r = LIBUSB_ERROR_INVALID_PARAM;
2323+
break;
2324+
}
23232325

2324-
if (NULL == ctx) {
2325-
usbi_mutex_static_lock(&default_context_lock);
2326-
default_context_options[option].is_set = 1;
2327-
if (LIBUSB_OPTION_LOG_LEVEL == option) {
2328-
default_context_options[option].arg.ival = arg;
2329-
} else if (LIBUSB_OPTION_LOG_CB) {
2330-
default_context_options[option].arg.log_cbval = log_cb;
2326+
if (NULL == ctx) {
2327+
usbi_mutex_static_lock(&default_context_lock);
2328+
default_context_options[option].is_set = 1;
2329+
if (LIBUSB_OPTION_LOG_LEVEL == option) {
2330+
default_context_options[option].arg.ival = arg;
2331+
} else if (LIBUSB_OPTION_LOG_CB == option) {
2332+
default_context_options[option].arg.log_cbval = log_cb;
2333+
}
2334+
usbi_mutex_static_unlock(&default_context_lock);
23312335
}
2332-
usbi_mutex_static_unlock(&default_context_lock);
2333-
}
23342336

2335-
ctx = usbi_get_context(ctx);
2336-
if (NULL == ctx) {
2337-
libusb_set_log_cb_internal(NULL, log_cb, LIBUSB_LOG_CB_GLOBAL);
2338-
return LIBUSB_SUCCESS;
2339-
}
2337+
ctx = usbi_get_context(ctx);
2338+
if (NULL == ctx) {
2339+
libusb_set_log_cb_internal(NULL, log_cb, LIBUSB_LOG_CB_GLOBAL);
2340+
break;
2341+
}
23402342

2341-
switch (option) {
2342-
case LIBUSB_OPTION_LOG_LEVEL:
2343+
switch (option) {
2344+
case LIBUSB_OPTION_LOG_LEVEL:
23432345
#if defined(ENABLE_LOGGING) && !defined(ENABLE_DEBUG_LOGGING)
2344-
if (!ctx->debug_fixed)
2345-
ctx->debug = (enum libusb_log_level)arg;
2346+
if (!ctx->debug_fixed)
2347+
ctx->debug = (enum libusb_log_level)arg;
23462348
#endif
2347-
break;
2349+
break;
23482350

2349-
/* Handle all backend-specific options here */
2350-
case LIBUSB_OPTION_USE_USBDK:
2351-
case LIBUSB_OPTION_NO_DEVICE_DISCOVERY:
2352-
case LIBUSB_OPTION_WINUSB_RAW_IO:
2353-
if (usbi_backend.set_option)
2354-
return usbi_backend.set_option(ctx, option, ap);
2351+
/* Handle all backend-specific options here */
2352+
case LIBUSB_OPTION_USE_USBDK:
2353+
case LIBUSB_OPTION_NO_DEVICE_DISCOVERY:
2354+
case LIBUSB_OPTION_WINUSB_RAW_IO:
2355+
if (usbi_backend.set_option) {
2356+
r = usbi_backend.set_option(ctx, option, ap);
2357+
break;
2358+
}
23552359

2356-
return LIBUSB_ERROR_NOT_SUPPORTED;
2357-
break;
2360+
r = LIBUSB_ERROR_NOT_SUPPORTED;
2361+
break;
23582362

2359-
case LIBUSB_OPTION_LOG_CB:
2360-
libusb_set_log_cb_internal(ctx, log_cb, LIBUSB_LOG_CB_CONTEXT);
2361-
break;
2362-
default:
2363-
return LIBUSB_ERROR_INVALID_PARAM;
2364-
}
2363+
case LIBUSB_OPTION_LOG_CB:
2364+
libusb_set_log_cb_internal(ctx, log_cb, LIBUSB_LOG_CB_CONTEXT);
2365+
break;
2366+
default:
2367+
r = LIBUSB_ERROR_INVALID_PARAM;
2368+
}
2369+
} while (0);
23652370

2366-
return LIBUSB_SUCCESS;;
2371+
va_end(ap);
2372+
2373+
return r;
23672374
}
23682375

23692376
#if defined(ENABLE_LOGGING) && !defined(ENABLE_DEBUG_LOGGING)
@@ -2448,8 +2455,8 @@ int API_EXPORTED libusb_init_context(libusb_context **ctx, const struct libusb_i
24482455
return LIBUSB_ERROR_NO_MEM;
24492456
}
24502457

2451-
_ctx->debug = LIBUSB_LOG_LEVEL_NONE;
24522458
#if defined(ENABLE_LOGGING) && !defined(ENABLE_DEBUG_LOGGING)
2459+
_ctx->debug = LIBUSB_LOG_LEVEL_NONE;
24532460
if (getenv("LIBUSB_DEBUG")) {
24542461
_ctx->debug = get_env_debug_level();
24552462
_ctx->debug_fixed = 1;

0 commit comments

Comments
 (0)