Skip to content

Commit

Permalink
Change libusb_init_option to fix libusb_set_option() on big-endian
Browse files Browse the repository at this point in the history
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 libusb#1416

Signed-off-by: Tormod Volden <[email protected]>
  • Loading branch information
tormodvolden committed Jan 19, 2024
1 parent 31dfa14 commit 6d5c31f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion libusb/libusb.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down

0 comments on commit 6d5c31f

Please sign in to comment.