diff options
author | Marek Olšák <marek.olsak@amd.com> | 2024-07-10 08:31:25 -0400 |
---|---|---|
committer | Marge Bot <emma+marge@anholt.net> | 2024-07-17 10:29:12 +0000 |
commit | ace7c32333521d18ee0db44da24132da70c23c22 (patch) | |
tree | 985790a4c0117a9a90cda88d4ca5ffa187fdceee /src | |
parent | 287ed620d0de450fd1b8141e14227a2033434715 (diff) |
util: don't use variable names that can appear in args of idalloc foreach macros
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30106>
Diffstat (limited to 'src')
-rw-r--r-- | src/util/u_idalloc.h | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/util/u_idalloc.h b/src/util/u_idalloc.h index eac0b68575d..d29f3d185c6 100644 --- a/src/util/u_idalloc.h +++ b/src/util/u_idalloc.h @@ -70,20 +70,20 @@ void util_idalloc_reserve(struct util_idalloc *buf, unsigned id); #define util_idalloc_foreach(buf, id) \ - for (uint32_t i = 0, mask = (buf)->num_set_elements ? (buf)->data[0] : 0, id, \ - count = (buf)->num_used; \ - i < count; mask = ++i < count ? (buf)->data[i] : 0) \ - while (mask) \ - if ((id = i * 32 + u_bit_scan(&mask)), true) + for (uint32_t _i = 0, _mask = (buf)->num_set_elements ? (buf)->data[0] : 0, id, \ + _count = (buf)->num_used; \ + _i < _count; _mask = ++_i < _count ? (buf)->data[_i] : 0) \ + while (_mask) \ + if ((id = _i * 32 + u_bit_scan(&_mask)), true) /* This allows freeing IDs while iterating, excluding ID=0. */ #define util_idalloc_foreach_no_zero_safe(buf, id) \ - for (uint32_t i = 0, bit, id, count = (buf)->num_set_elements, \ - mask = count ? (buf)->data[0] & ~0x1 : 0; \ - i < count; mask = ++i < count ? (buf)->data[i] : 0) \ - while (mask) \ - if ((bit = u_bit_scan(&mask), id = i * 32 + bit), \ - (buf)->data[i] & BITFIELD_BIT(bit)) + for (uint32_t _i = 0, _bit, id, _count = (buf)->num_set_elements, \ + _mask = _count ? (buf)->data[0] & ~0x1 : 0; \ + _i < _count; _mask = ++_i < _count ? (buf)->data[_i] : 0) \ + while (_mask) \ + if ((_bit = u_bit_scan(&_mask), id = _i * 32 + _bit), \ + (buf)->data[_i] & BITFIELD_BIT(_bit)) /* Thread-safe variant. */ struct util_idalloc_mt { |