From 6d5c31f5d77659dc803c31f9ac2f5d9964d11c42 Mon Sep 17 00:00:00 2001 From: Tormod Volden Date: Fri, 19 Jan 2024 10:05:46 +0100 Subject: [PATCH] Change libusb_init_option to fix libusb_set_option() on big-endian libusb_set_option() is a variadic function, so the type of the arguments is not clearly defined. When called with LIBUSB_OPTION_LOG_LEVEL, the argument is read with va_arg() as an int, which matches the type used when passing constants, and also most of the internal calls and the calls in the examples. However the internal call site in libusb_init_context() passes the ival element of the libusb_init_option struct directly, which is of type int64_t. This breaks on big-endian architectures like PowerPC. Therefore change the libusb_init_option struct to use int here as well. Thanks to Aurelien Jarno for reporting and initial patch. Closes #1416 Signed-off-by: Tormod Volden --- libusb/libusb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libusb/libusb.h b/libusb/libusb.h index ec14e7e79..ffdb96bdb 100644 --- a/libusb/libusb.h +++ b/libusb/libusb.h @@ -1538,7 +1538,7 @@ struct libusb_init_option { enum libusb_option option; /** An integer value used by the option (if applicable). */ union { - int64_t ival; + int ival; libusb_log_cb log_cbval; } value; };