From: Jan Blunck Date: Tue, 14 Feb 2017 14:36:06 +0000 (+0100) Subject: eal: ensure constness of container_of target X-Git-Tag: spdx-start~4440 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=b2fba636909e57f99d6e10781fbed95954128b22;p=dpdk.git 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 --- 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