mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-03-14 17:20:42 +01:00
util/bitset: add an assert for big BITSET_EXTRACT
This just bit me. Add an assert to catch the next person who doesn't read the function signature and tries to extract 64-bits out and wonders why things are silently broken. Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@intel.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39892>
This commit is contained in:
parent
f55e87db93
commit
fc3951cfde
1 changed files with 1 additions and 0 deletions
|
|
@ -282,6 +282,7 @@ __bitset_clear_range(BITSET_WORD *r, int start, int end)
|
|||
static inline unsigned
|
||||
__bitset_extract(const BITSET_WORD *r, unsigned start, unsigned count)
|
||||
{
|
||||
assert(count <= BITSET_WORDBITS);
|
||||
unsigned shift = start % BITSET_WORDBITS;
|
||||
BITSET_WORD lower = r[BITSET_BITWORD(start)] >> shift;
|
||||
BITSET_WORD upper = shift ? r[BITSET_BITWORD(start + count - 1)] << (BITSET_WORDBITS - shift) : 0;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue