From patchwork Fri Jun 19 17:34:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cyril Chemparathy X-Patchwork-Id: 5622 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 DF1A3C91C; Fri, 19 Jun 2015 19:35:15 +0200 (CEST) Received: from sclab-apps-2.localdomain (sc-fw1.tilera.com [12.218.212.162]) by dpdk.org (Postfix) with ESMTP id 1EE2CC8AC for ; Fri, 19 Jun 2015 19:35:04 +0200 (CEST) X-CheckPoint: {558452C7-6-A3D4DA0C-C0000002} Received: by sclab-apps-2.localdomain (Postfix, from userid 1318) id 08AAF22048F; Fri, 19 Jun 2015 10:35:02 -0700 (PDT) From: Cyril Chemparathy To: dev@dpdk.org Date: Fri, 19 Jun 2015 10:34:44 -0700 Message-Id: <1434735293-15469-2-git-send-email-cchemparathy@ezchip.com> X-Mailer: git-send-email 2.1.2 In-Reply-To: <1434735293-15469-1-git-send-email-cchemparathy@ezchip.com> References: <1434735293-15469-1-git-send-email-cchemparathy@ezchip.com> Subject: [dpdk-dev] [PATCH v2 01/10] mempool: 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 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 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 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); } /**