From patchwork Mon Jun 22 18:34:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cyril Chemparathy X-Patchwork-Id: 5668 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 860BFC8A2; Mon, 22 Jun 2015 20:34:46 +0200 (CEST) Received: from sclab-apps-2.localdomain (sc-fw1.tilera.com [12.218.212.162]) by dpdk.org (Postfix) with ESMTP id F0983C862 for ; Mon, 22 Jun 2015 20:34:31 +0200 (CEST) X-CheckPoint: {55885535-7-A3D4DA0C-C0000002} Received: by sclab-apps-2.localdomain (Postfix, from userid 1318) id 8E19A2204F2; Mon, 22 Jun 2015 11:34:29 -0700 (PDT) From: Cyril Chemparathy To: dev@dpdk.org Date: Mon, 22 Jun 2015 11:34:16 -0700 Message-Id: <1434998063-15739-3-git-send-email-cchemparathy@ezchip.com> X-Mailer: git-send-email 2.1.2 In-Reply-To: <1434998063-15739-1-git-send-email-cchemparathy@ezchip.com> References: <1434998063-15739-1-git-send-email-cchemparathy@ezchip.com> Subject: [dpdk-dev] [PATCH v4 2/9] 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 *). Change-Id: I60d9b7a9205ff0befb8dbb4cdcb1df6f9d9d0250 Signed-off-by: Cyril Chemparathy --- 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 6c9cfd6..6efd2b5 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); } /**