From b2fba636909e57f99d6e10781fbed95954128b22 Mon Sep 17 00:00:00 2001 From: Jan Blunck Date: Tue, 14 Feb 2017 15:36:06 +0100 Subject: [PATCH] eal: ensure constness of container_of target This adds a check to ensure that the container_of() macro is not used to cast away (remove) constness. Signed-off-by: Jan Blunck Acked-by: Bruce Richardson --- lib/librte_eal/common/include/rte_common.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/common/include/rte_common.h index c4217082c9..e057f6e213 100644 --- a/lib/librte_eal/common/include/rte_common.h +++ b/lib/librte_eal/common/include/rte_common.h @@ -348,6 +348,8 @@ rte_bsf32(uint32_t v) #ifndef container_of #define container_of(ptr, type, member) __extension__ ({ \ const typeof(((type *)0)->member) *_ptr = (ptr); \ + __attribute__((unused)) type *_target_ptr = \ + (type *)(ptr); \ (type *)(((uintptr_t)_ptr) - offsetof(type, member)); \ }) #endif -- 2.20.1