From: Jan Blunck Date: Tue, 14 Feb 2017 14:36:05 +0000 (+0100) Subject: eal: fix container_of macro for const members X-Git-Tag: spdx-start~4441 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=7cfd28057832898ab1793603b2d1724039a9e18a;p=dpdk.git eal: fix container_of macro for const members This fixes the usage of structure members that are declared const to get a pointer to the embedding parent structure. 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 8dda3e2944..c4217082c9 100644 --- a/lib/librte_eal/common/include/rte_common.h +++ b/lib/librte_eal/common/include/rte_common.h @@ -347,8 +347,9 @@ rte_bsf32(uint32_t v) */ #ifndef container_of #define container_of(ptr, type, member) __extension__ ({ \ - typeof(((type *)0)->member) *_ptr = (ptr); \ - (type *)(((char *)_ptr) - offsetof(type, member)); }) + const typeof(((type *)0)->member) *_ptr = (ptr); \ + (type *)(((uintptr_t)_ptr) - offsetof(type, member)); \ + }) #endif #define _RTE_STR(x) #x