OSDN Git Service

mesa: fix MSVC bitshift overflow warnings
authorBrian Paul <brianp@vmware.com>
Fri, 30 Mar 2018 15:06:01 +0000 (09:06 -0600)
committerBrian Paul <brianp@vmware.com>
Fri, 30 Mar 2018 17:04:32 +0000 (11:04 -0600)
commitcdc34e2cea73b7932e51ad407595d487d2d565c3
tree018d53c74c1fab972753307ab5ede005fca23393
parentfa18a427e929ecc04a9980e517db96663debea29
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 <mathias.froehlich@web.de>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
src/mesa/main/mtypes.h