DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] common/sfc: replace out of bounds condition with static_assert
@ 2024-01-18 20:18 Stephen Hemminger
  2024-01-18 23:05 ` Morten Brørup
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Stephen Hemminger @ 2024-01-18 20:18 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Andrew Rybchenko

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


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2024-02-13  9:40 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-18 20:18 [PATCH] common/sfc: replace out of bounds condition with static_assert Stephen Hemminger
2024-01-18 23:05 ` Morten Brørup
2024-02-13  7:47   ` Andrew Rybchenko
2024-01-19 22:13 ` [PATCH v2] " Stephen Hemminger
2024-01-20  7:53   ` Morten Brørup
2024-02-07 19:10   ` Ferruh Yigit
2024-02-07 22:34     ` Stephen Hemminger
2024-02-07 22:36     ` Stephen Hemminger
2024-02-07 23:30       ` Ferruh Yigit
2024-02-11 17:41         ` Stephen Hemminger
2024-02-11 22:24 ` [PATCH] " Stephen Hemminger
2024-02-12  5:48 ` [PATCH v4] " Stephen Hemminger
2024-02-12 12:09   ` Ferruh Yigit
2024-02-13  9:39   ` Ferruh Yigit

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).