freedreno: Fix UBSan failures in cffdec's (uint8_t)x << 24

Types <32 bit get promoted to int32_t when you do expressions on them
(thus why (u8)x << 8 works at all), but shifting into the top bit of the
signed int is undefined behavior.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6360>
This commit is contained in:
Eric Anholt 2020-08-17 13:56:38 -07:00 committed by Marge Bot
parent d5a80781aa
commit 21df8b3e08
1 changed files with 3 additions and 3 deletions

View File

@ -68,7 +68,7 @@ dump_hex(const void *buf, int sz)
d |= *(ptr++) << 0;
d |= *(ptr++) << 8;
d |= *(ptr++) << 16;
d |= *(ptr++) << 24;
d |= (uint32_t)*(ptr++) << 24;
printf("%08x", d);
@ -99,7 +99,7 @@ dump_float(const void *buf, int sz)
d |= *(ptr++) << 0;
d |= *(ptr++) << 8;
d |= *(ptr++) << 16;
d |= *(ptr++) << 24;
d |= (uint32_t)*(ptr++) << 24;
printf("%8f", d2f(d));
@ -171,7 +171,7 @@ dump_hex_ascii(const void *buf, int sz, int level)
d |= *(ptr++) << 0;
d |= *(ptr++) << 8;
d |= *(ptr++) << 16;
d |= *(ptr++) << 24;
d |= (uint32_t)*(ptr++) << 24;
printf("%08x", d);