diff mbox

[dpdk-dev,v3,01/10] mempool: silence -Wcast-align on pointer arithmetic

Message ID 1434740232-10954-2-git-send-email-cchemparathy@ezchip.com (mailing list archive)
State Superseded, archived
Headers show

Commit Message

Cyril Chemparathy June 19, 2015, 6:57 p.m. UTC
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 *).

Acked-by: Olivier Matz <olivier.matz@6wind.com>
Signed-off-by: Cyril Chemparathy <cchemparathy@ezchip.com>
---
 lib/librte_mempool/rte_mempool.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
diff mbox

Patch

diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h
index bc2bae0..8be040b 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);
 }
 
 /**