From f1023571e8ce7ccb6ec7bc115240cb76aef3e5e5 Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Tue, 31 May 2022 10:24:38 +0200 Subject: [PATCH] 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 Reviewed-by: Jesse Natalie Part-of: --- src/util/macros.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/util/macros.h b/src/util/macros.h index fafe59e04cc..b48e10667ef 100644 --- a/src/util/macros.h +++ b/src/util/macros.h @@ -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