From: John Stultz Date: Thu, 12 Mar 2020 22:21:29 +0000 (+0000) Subject: etnaviv: Avoid shift overflow X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e3bbe1fa65ede1e2504510d15b1c439fb81328fa;p=mesa.git etnaviv: Avoid shift overflow Building with AOSP I'm seeing: external/mesa3d/src/gallium/drivers/etnaviv/etnaviv_screen.c:245:31: error: signed shift result (0x100000000) requires 34 bits to represent, but 'int' only has 32 bits [-Werror,-Wshift-overflow] system_memory = 4096 << 20; system_memory is a uint_64t, so this patch addresses the issue by casting 4096 to a unint_64t before the shift is done. Reviewed-by: Christian Gmeiner Signed-off-by: John Stultz Part-of: --- diff --git a/src/gallium/drivers/etnaviv/etnaviv_screen.c b/src/gallium/drivers/etnaviv/etnaviv_screen.c index d5fd35cbd77..ad33790b427 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_screen.c +++ b/src/gallium/drivers/etnaviv/etnaviv_screen.c @@ -243,7 +243,7 @@ etna_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param) uint64_t system_memory; if (!os_get_total_physical_memory(&system_memory)) - system_memory = 4096 << 20; + system_memory = (uint64_t)4096 << 20; return MIN2(system_memory / 32, 64 * 1024 * 1024); }