util: use static_assert directly

For some reason, Clang doesn't love the STATIC_ASSERT implementation
we're about switch to in this *one* particular case. Other cases seems
to work fine, so let's just use static_assert directly here.

It lets us give a better error string anyway, so yay.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16670>
This commit is contained in:
Erik Faye-Lund 2022-05-31 10:24:38 +02:00 committed by Marge Bot
parent 873ec432b3
commit f1023571e8
1 changed files with 3 additions and 3 deletions

View File

@ -104,9 +104,9 @@
__builtin_types_compatible_p(__typeof__(a), __typeof__(b))
# define container_of(ptr, type, member) ({ \
uint8_t *__mptr = (uint8_t *)(ptr); \
STATIC_ASSERT(__same_type(*(ptr), ((type *)0)->member) || \
__same_type(*(ptr), void) || \
!"pointer type mismatch in container_of()"); \
static_assert(__same_type(*(ptr), ((type *)0)->member) || \
__same_type(*(ptr), void), \
"pointer type mismatch in container_of()"); \
((type *)(__mptr - offsetof(type, member))); \
})
#endif