From cb811ba4638cb5c99df85185305206d8aab450c3 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 3 Feb 2024 11:12:57 -0800 Subject: [PATCH] Fixed warning C4366: The result of the unary '&' operator may be unaligned --- src/joystick/hidapi/SDL_hidapi_xboxone.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/joystick/hidapi/SDL_hidapi_xboxone.c b/src/joystick/hidapi/SDL_hidapi_xboxone.c index 440d3e7d26..c9b48ab7c2 100644 --- a/src/joystick/hidapi/SDL_hidapi_xboxone.c +++ b/src/joystick/hidapi/SDL_hidapi_xboxone.c @@ -1225,17 +1225,19 @@ static int EncodeVariableInt(Uint8 *buf, Uint32 val) return i + 1; } -static int DecodeVariableInt(const Uint8 *data, int len, Uint32 *val) +static int DecodeVariableInt(const Uint8 *data, int len, void *out) { int i; + Uint32 val = 0; - for (i = 0; i < sizeof(*val) && i < len; i++) { - *val |= (data[i] & 0x7F) << (i * 7); + for (i = 0; i < sizeof(val) && i < len; i++) { + val |= (data[i] & 0x7F) << (i * 7); if (!(data[i] & 0x80)) { break; } } + SDL_memcpy(out, &val, sizeof(val)); return i + 1; }