[PATCH v3 4/5] mempool: avoid floating point expression in static assertion

Stephen Hemminger stephen at networkplumber.org
Tue Jan 16 19:41:14 CET 2024


Clang does not handle casts in static_assert() expressions.
It doesn't like use of floating point to calculate threshold.
Use a different expression with same effect; yes this will cause
checkpatch nag.

Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
---
 lib/mempool/rte_mempool.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/lib/mempool/rte_mempool.c b/lib/mempool/rte_mempool.c
index b7a19bea7185..ba3a54cfc298 100644
--- a/lib/mempool/rte_mempool.c
+++ b/lib/mempool/rte_mempool.c
@@ -50,9 +50,7 @@ static void
 mempool_event_callback_invoke(enum rte_mempool_event event,
 			      struct rte_mempool *mp);
 
-#define CACHE_FLUSHTHRESH_MULTIPLIER 1.5
-#define CALC_CACHE_FLUSHTHRESH(c)	\
-	((typeof(c))((c) * CACHE_FLUSHTHRESH_MULTIPLIER))
+#define CALC_CACHE_FLUSHTHRESH(c) ((c) + (c) / 2)
 
 #if defined(RTE_ARCH_X86)
 /*
-- 
2.43.0



More information about the dev mailing list