From 62b7958cd0ec03ff1e15144f0104728458621d1d Mon Sep 17 00:00:00 2001 From: Nicolai Hähnle Date: Fri, 29 Apr 2016 21:56:25 -0500 Subject: gallium: fix various undefined left shifts into sign bit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Funnily enough, some of these were turned into a compile-time error by gcc with -fsanitize=undefined ("initializer is not a constant"). Reviewed-by: Brian Paul Reviewed-by: Michel Dänzer Reviewed-by: Marek Olšák --- src/gallium/auxiliary/tgsi/tgsi_ureg.c | 2 +- src/gallium/auxiliary/util/u_pack_color.h | 2 +- src/gallium/auxiliary/util/u_pstipple.c | 2 +- src/gallium/drivers/softpipe/sp_quad_stipple.c | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c index 021b81f3874..43b8bb10f1c 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c @@ -1735,7 +1735,7 @@ static void emit_decls( struct ureg_program *ureg ) if (ureg->processor == PIPE_SHADER_VERTEX) { for (i = 0; i < PIPE_MAX_ATTRIBS; i++) { - if (ureg->vs_inputs[i/32] & (1 << (i%32))) { + if (ureg->vs_inputs[i/32] & (1u << (i%32))) { emit_decl_range( ureg, TGSI_FILE_INPUT, i, 1 ); } } diff --git a/src/gallium/auxiliary/util/u_pack_color.h b/src/gallium/auxiliary/util/u_pack_color.h index b882502b7ba..f9f41609b44 100644 --- a/src/gallium/auxiliary/util/u_pack_color.h +++ b/src/gallium/auxiliary/util/u_pack_color.h @@ -367,7 +367,7 @@ util_pack_color(const float rgba[4], enum pipe_format format, union util_color * return; case PIPE_FORMAT_BGRX8888_UNORM: { - uc->ui[0] = (0xff << 24) | (r << 16) | (g << 8) | b; + uc->ui[0] = (0xffu << 24) | (r << 16) | (g << 8) | b; } return; case PIPE_FORMAT_ARGB8888_UNORM: diff --git a/src/gallium/auxiliary/util/u_pstipple.c b/src/gallium/auxiliary/util/u_pstipple.c index 3ae8923f953..f6ea535c413 100644 --- a/src/gallium/auxiliary/util/u_pstipple.c +++ b/src/gallium/auxiliary/util/u_pstipple.c @@ -63,7 +63,7 @@ util_pstipple_update_stipple_texture(struct pipe_context *pipe, struct pipe_resource *tex, const uint32_t pattern[32]) { - static const uint bit31 = 1 << 31; + static const uint bit31 = 1u << 31; struct pipe_transfer *transfer; ubyte *data; int i, j; diff --git a/src/gallium/drivers/softpipe/sp_quad_stipple.c b/src/gallium/drivers/softpipe/sp_quad_stipple.c index a0527a596a6..4b29c2eb221 100644 --- a/src/gallium/drivers/softpipe/sp_quad_stipple.c +++ b/src/gallium/drivers/softpipe/sp_quad_stipple.c @@ -16,8 +16,8 @@ static void stipple_quad(struct quad_stage *qs, struct quad_header *quads[], unsigned nr) { - static const uint bit31 = 1 << 31; - static const uint bit30 = 1 << 30; + static const uint bit31 = 1u << 31; + static const uint bit30 = 1u << 30; unsigned pass = nr; struct softpipe_context *softpipe = qs->softpipe; -- cgit v1.2.3