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:
Alyssa Rosenzweig 2026-02-13 10:58:42 -05:00 committed by Marge Bot
parent f55e87db93
commit fc3951cfde

View file

@ -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;