From 5c35f0e40eb5303a5dc89912aa37ca75f73b935e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Andr=C3=A9=20Vadla=20Ravn=C3=A5s?= Date: Thu, 6 Jan 2022 00:29:48 +0100 Subject: [PATCH] decode: Fix LOAD_LE_8() on 32-bit systems Where size_t is only 32 bits wide, and we end up losing the upper bits. GCC catches this and emits a warning such as: warning: left shift count >= width of type [-Wshift-count-overflow] --- decode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/decode.c b/decode.c index 55d4a97..ef400b4 100644 --- a/decode.c +++ b/decode.c @@ -43,7 +43,7 @@ table_walk(unsigned cur_idx, unsigned entry_idx, unsigned* out_kind) { return (entry & ~ENTRY_MASK) >> 1; } -#define LOAD_LE_1(buf) ((size_t) *(uint8_t*) (buf)) +#define LOAD_LE_1(buf) ((uint64_t) *(uint8_t*) (buf)) #define LOAD_LE_2(buf) (LOAD_LE_1(buf) | LOAD_LE_1((uint8_t*) (buf) + 1)<<8) #define LOAD_LE_3(buf) (LOAD_LE_2(buf) | LOAD_LE_1((uint8_t*) (buf) + 2)<<16) #define LOAD_LE_4(buf) (LOAD_LE_2(buf) | LOAD_LE_2((uint8_t*) (buf) + 2)<<16)