From: Cyril Chemparathy Date: Mon, 22 Jun 2015 18:34:16 +0000 (-0700) Subject: mbuf: silence warning on pointer arithmetic X-Git-Tag: spdx-start~8975 X-Git-Url: http://git.droids-corp.org/?p=dpdk.git;a=commitdiff_plain;h=7755baae8378671d5b5a74990ca359c07f227826 mbuf: silence warning on pointer arithmetic Translating from an mbuf element to the mbuf 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 Acked-by: Olivier Matz --- diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index eed481e222..70da79707e 100644 --- a/lib/librte_mbuf/rte_mbuf.h +++ b/lib/librte_mbuf/rte_mbuf.h @@ -347,13 +347,7 @@ static inline uint16_t rte_pktmbuf_priv_size(struct rte_mempool *mp); static inline struct rte_mbuf * rte_mbuf_from_indirect(struct rte_mbuf *mi) { - struct rte_mbuf *md; - - /* mi->buf_addr and mi->priv_size correspond to buffer and - * private size of the direct mbuf */ - md = (struct rte_mbuf *)((char *)mi->buf_addr - sizeof(*mi) - - mi->priv_size); - return md; + return RTE_PTR_SUB(mi->buf_addr, sizeof(*mi) + mi->priv_size); } /**