[PATCH] common/sfc: replace out of bounds condition with static_assert
Stephen Hemminger
stephen at networkplumber.org
Thu Jan 18 21:18:09 CET 2024
The sfc base code had its own definition of static assertions
using the out of bound array access hack. Replace it with a
static_assert like rte_common.h.
Fixes: f67e4719147d ("net/sfc/base: fix coding style")
Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
---
drivers/common/sfc_efx/base/efx.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/common/sfc_efx/base/efx.h b/drivers/common/sfc_efx/base/efx.h
index 3312c2fa8f81..9ce266c43610 100644
--- a/drivers/common/sfc_efx/base/efx.h
+++ b/drivers/common/sfc_efx/base/efx.h
@@ -17,8 +17,8 @@
extern "C" {
#endif
-#define EFX_STATIC_ASSERT(_cond) \
- ((void)sizeof (char[(_cond) ? 1 : -1]))
+#define EFX_STATIC_ASSERT(_cond) \
+ do { static_assert((_cond), "assert failed" #_cond); } while (0)
#define EFX_ARRAY_SIZE(_array) \
(sizeof (_array) / sizeof ((_array)[0]))
--
2.43.0
More information about the dev
mailing list