From 18ab42644b134e3aecd8ea14df3d30eb9b6a80f4 Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Tue, 13 Aug 2019 13:02:24 +0200 Subject: [PATCH] gallium/util: widen type before multiplication This method returns size_t, but the multiplication multiplies two integers, leading to overflow rather than type widening. Noticed by compiling with MSVC, which emits a warning. Signed-off-by: Erik Faye-Lund Reviewed-by: Eric Anholt --- src/gallium/auxiliary/util/u_format.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h index fe348aa55c8..eb8c2f6ae3f 100644 --- a/src/gallium/auxiliary/util/u_format.h +++ b/src/gallium/auxiliary/util/u_format.h @@ -870,7 +870,7 @@ static inline size_t util_format_get_stride(enum pipe_format format, unsigned width) { - return util_format_get_nblocksx(format, width) * util_format_get_blocksize(format); + return (size_t)util_format_get_nblocksx(format, width) * util_format_get_blocksize(format); } static inline size_t -- 2.30.2