From mboxrd@z Thu Jan 1 00:00:00 1970 From: Cyril Chemparathy Subject: [PATCH 02/10] mempool: silence -Wcast-align on pointer arithmetic Date: Wed, 29 Apr 2015 09:15:26 -0700 Message-ID: <1430324134-25654-3-git-send-email-cchemparathy@ezchip.com> References: <1430324134-25654-1-git-send-email-cchemparathy@ezchip.com> To: dev-VfR2kkLFssw@public.gmane.org Return-path: In-Reply-To: <1430324134-25654-1-git-send-email-cchemparathy-d5a29ZRxExrQT0dZR+AlfA@public.gmane.org> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces-VfR2kkLFssw@public.gmane.org Sender: "dev" Translating from a mempool object to the mempool pointer does not break alignment constraints. However, the compiler is unaware of this fact and complains on -Wcast-align. This patch modifies the code to use RTE_PTR_SUB(), thereby silencing the compiler by casting through (void *). Signed-off-by: Cyril Chemparathy --- lib/librte_mempool/rte_mempool.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h index 9001312..1fb4184 100644 --- a/lib/librte_mempool/rte_mempool.h +++ b/lib/librte_mempool/rte_mempool.h @@ -236,15 +236,13 @@ struct rte_mempool { */ static inline struct rte_mempool **__mempool_from_obj(void *obj) { - struct rte_mempool **mpp; unsigned off; off = sizeof(struct rte_mempool *); #ifdef RTE_LIBRTE_MEMPOOL_DEBUG off += sizeof(uint64_t); #endif - mpp = (struct rte_mempool **)((char *)obj - off); - return mpp; + return RTE_PTR_SUB(obj, off); } /** -- 2.1.2