eal: ensure constness of container_of target
authorJan Blunck <jblunck@infradead.org>
Tue, 14 Feb 2017 14:36:06 +0000 (15:36 +0100)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Wed, 8 Mar 2017 13:04:29 +0000 (14:04 +0100)
This adds a check to ensure that the container_of() macro is not used to
cast away (remove) constness.

Signed-off-by: Jan Blunck <jblunck@infradead.org>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
lib/librte_eal/common/include/rte_common.h

index c421708..e057f6e 100644 (file)
@@ -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