diff options
author | Jason Ekstrand <[email protected]> | 2018-10-29 17:17:43 -0500 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2019-01-29 18:43:55 +0000 |
commit | 009c0bd84020589c21ce25e5a5317abdd63cdb3a (patch) | |
tree | 2adcdf5fa85f9443351bc6264978508a8ea7fd1f /src/mesa/drivers/dri | |
parent | 077b9557a4e18e267f2c7966d643a457f26644e2 (diff) |
intel/defines: Explicitly cast to uint32_t in SET_FIELD and SET_BITS
If you pass a bool in as the value to set, the C standard says that it
gets converted to an int prior to shifting. If you try to set a bool to
bit 31, this lands you in undefined behavior. It's better just to add
the explicit cast and let the compiler delete it for us.
Reviewed-by: Iago Toral Quiroga <[email protected]>
Diffstat (limited to 'src/mesa/drivers/dri')
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_defines.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_defines.h b/src/mesa/drivers/dri/i965/brw_defines.h index 5017c41ab24..2729a54e144 100644 --- a/src/mesa/drivers/dri/i965/brw_defines.h +++ b/src/mesa/drivers/dri/i965/brw_defines.h @@ -38,7 +38,7 @@ /* Using the GNU statement expression extension */ #define SET_FIELD(value, field) \ ({ \ - uint32_t fieldval = (value) << field ## _SHIFT; \ + uint32_t fieldval = (uint32_t)(value) << field ## _SHIFT; \ assert((fieldval & ~ field ## _MASK) == 0); \ fieldval & field ## _MASK; \ }) |