DPDK patches and discussions
 help / color / mirror / Atom feed
From: Cyril Chemparathy <cchemparathy@ezchip.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH v3 01/10] mempool: silence -Wcast-align on pointer arithmetic
Date: Fri, 19 Jun 2015 11:57:03 -0700	[thread overview]
Message-ID: <1434740232-10954-2-git-send-email-cchemparathy@ezchip.com> (raw)
In-Reply-To: <1434740232-10954-1-git-send-email-cchemparathy@ezchip.com>

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 --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);
 }
 
 /**
-- 
2.1.2

  reply	other threads:[~2015-06-19 18:57 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-19 18:57 [dpdk-dev] [PATCH v3 00/10] Improve cast alignment for strict aligned machines Cyril Chemparathy
2015-06-19 18:57 ` Cyril Chemparathy [this message]
2015-06-19 18:57 ` [dpdk-dev] [PATCH v3 02/10] mbuf: silence -Wcast-align on pointer arithmetic Cyril Chemparathy
2015-06-19 18:57 ` [dpdk-dev] [PATCH v3 03/10] ethdev: " Cyril Chemparathy
2015-06-19 18:57 ` [dpdk-dev] [PATCH v3 04/10] hash: " Cyril Chemparathy
2015-06-19 18:57 ` [dpdk-dev] [PATCH v3 05/10] eal: add and use unaligned integer types Cyril Chemparathy
2015-06-19 18:57 ` [dpdk-dev] [PATCH v3 06/10] app/test-pmd: pack simple_gre_hdr Cyril Chemparathy
2015-06-19 18:57 ` [dpdk-dev] [PATCH v3 07/10] app/test: use struct ether_addr instead of a byte array cast Cyril Chemparathy
2015-06-19 18:57 ` [dpdk-dev] [PATCH v3 08/10] librte_mbuf: Add rte_pktmbuf_mtod_offset() Cyril Chemparathy
2015-06-19 18:57 ` [dpdk-dev] [PATCH v3 09/10] librte_mbuf: Add transform for rte_pktmbuf_mtod_offset() Cyril Chemparathy
2015-06-19 18:57 ` [dpdk-dev] [PATCH v3 10/10] librte_mbuf: Apply mtod-offset.cocci transform Cyril Chemparathy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1434740232-10954-2-git-send-email-cchemparathy@ezchip.com \
    --to=cchemparathy@ezchip.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).