mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 20:28:04 +02:00
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 <itoral@igalia.com>
This commit is contained in:
parent
077b9557a4
commit
009c0bd840
2 changed files with 3 additions and 3 deletions
|
|
@ -41,14 +41,14 @@
|
|||
/* 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; \
|
||||
})
|
||||
|
||||
#define SET_BITS(value, high, low) \
|
||||
({ \
|
||||
const uint32_t fieldval = (value) << (low); \
|
||||
const uint32_t fieldval = (uint32_t)(value) << (low); \
|
||||
assert((fieldval & ~INTEL_MASK(high, low)) == 0); \
|
||||
fieldval & INTEL_MASK(high, low); \
|
||||
})
|
||||
|
|
|
|||
|
|
@ -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; \
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue