summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2018-03-30 09:06:01 -0600
committerBrian Paul <[email protected]>2018-03-30 11:04:32 -0600
commitcdc34e2cea73b7932e51ad407595d487d2d565c3 (patch)
tree018d53c74c1fab972753307ab5ede005fca23393 /src
parentfa18a427e929ecc04a9980e517db96663debea29 (diff)
mesa: fix MSVC bitshift overflow warnings
In the BITFIELD_MASK() macro, if b==32 the expression evaluates to ~0u, but the compiler still sees the expression (1 << 32) in the unused part and issues a warning about integer bitshift overflow. Fix that by using (b) % 32 to ensure the max shift is 31 bits. This issue has been present for a while, but shows up much more often because of the recent VBO changes. Reviewed-by: Mathias Fröhlich <[email protected]> Reviewed-by: Roland Scheidegger <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/mesa/main/mtypes.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 801bd17666f..b7a7b34a090 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -59,7 +59,7 @@ extern "C" {
#define BITFIELD_BIT(b) ((GLbitfield)1 << (b))
/** Set all bits up to excluding bit b */
#define BITFIELD_MASK(b) \
- ((b) == 32 ? (~(GLbitfield)0) : BITFIELD_BIT(b) - 1)
+ ((b) == 32 ? (~(GLbitfield)0) : BITFIELD_BIT((b) % 32) - 1)
/** Set count bits starting from bit b */
#define BITFIELD_RANGE(b, count) \
(BITFIELD_MASK((b) + (count)) & ~BITFIELD_MASK(b))