From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <cchemparathy@ezchip.com>
Received: from sclab-apps-2.localdomain (sc-fw1.tilera.com [12.218.212.162])
 by dpdk.org (Postfix) with ESMTP id E3CB2C900
 for <dev@dpdk.org>; Wed, 29 Apr 2015 18:15:55 +0200 (CEST)
X-CheckPoint: {554103BA-A-A3D4DA0C-C0000002}
Received: by sclab-apps-2.localdomain (Postfix, from userid 1318)
 id B826F220725; Wed, 29 Apr 2015 09:15:54 -0700 (PDT)
From: Cyril Chemparathy <cchemparathy@ezchip.com>
To: dev@dpdk.org
Date: Wed, 29 Apr 2015 09:15:28 -0700
Message-Id: <1430324134-25654-5-git-send-email-cchemparathy@ezchip.com>
X-Mailer: git-send-email 2.1.2
In-Reply-To: <1430324134-25654-1-git-send-email-cchemparathy@ezchip.com>
References: <1430324134-25654-1-git-send-email-cchemparathy@ezchip.com>
Subject: [dpdk-dev] [PATCH 04/10] mbuf: silence -Wcast-align on pointer
	arithmetic
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: patches and discussions about DPDK <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Wed, 29 Apr 2015 16:16:06 -0000

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 <cchemparathy@ezchip.com>
---
 lib/librte_mbuf/rte_mbuf.h | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 70b0987..5ddd8dd 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -337,13 +337,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);
 }
 
 /**
-- 
2.1.2