From 7cfd28057832898ab1793603b2d1724039a9e18a Mon Sep 17 00:00:00 2001 From: Jan Blunck Date: Tue, 14 Feb 2017 15:36:05 +0100 Subject: [PATCH] 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 --- lib/librte_eal/common/include/rte_common.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 -- 2.20.1