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]
This commit is contained in:
Ole André Vadla Ravnås
2022-01-06 00:29:48 +01:00
committed by aengelke
parent 4b42ddb567
commit 5c35f0e40e

View File

@@ -43,7 +43,7 @@ table_walk(unsigned cur_idx, unsigned entry_idx, unsigned* out_kind) {
return (entry & ~ENTRY_MASK) >> 1; 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_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_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) #define LOAD_LE_4(buf) (LOAD_LE_2(buf) | LOAD_LE_2((uint8_t*) (buf) + 2)<<16)