DPDK patches and discussions
 help / color / mirror / Atom feed
From: Joongi Kim <joongi@an.kaist.ac.kr>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 1/2] lib: Fix pointer arithmetic for C++
Date: Fri,  3 Jul 2015 21:51:02 +0900	[thread overview]
Message-ID: <1435927863-3398-1-git-send-email-joongi@an.kaist.ac.kr> (raw)

 * C++ requires explicit conversion of void pointer types to other
   pointer types.

 * This issue was introduced by previous commits 6cf14ce4 and 7755baae8.
   Two subsequent commits 2f935c12 and 7621d6a also have the same issue,
   I did not fix them because they are NOT headers potentially included
   by C++ sources.

Signed-off-by: Joongi Kim <joongi@an.kaist.ac.kr>
---
 lib/librte_malloc/malloc_elem.h  | 4 ++--
 lib/librte_mbuf/rte_mbuf.h       | 2 +-
 lib/librte_mempool/rte_mempool.c | 2 +-
 lib/librte_mempool/rte_mempool.h | 4 ++--
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/lib/librte_malloc/malloc_elem.h b/lib/librte_malloc/malloc_elem.h
index 9790b1a..2b18d06 100644
--- a/lib/librte_malloc/malloc_elem.h
+++ b/lib/librte_malloc/malloc_elem.h
@@ -124,10 +124,10 @@ malloc_elem_from_data(const void *data)
 	if (data == NULL)
 		return NULL;
 
-	struct malloc_elem *elem = RTE_PTR_SUB(data, MALLOC_ELEM_HEADER_LEN);
+	struct malloc_elem *elem = (struct malloc_elem *) RTE_PTR_SUB(data, MALLOC_ELEM_HEADER_LEN);
 	if (!malloc_elem_cookies_ok(elem))
 		return NULL;
-	return elem->state != ELEM_PAD ? elem:  RTE_PTR_SUB(elem, elem->pad);
+	return elem->state != ELEM_PAD ? elem: (struct malloc_elem *) RTE_PTR_SUB(elem, elem->pad);
 }
 
 /*
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 8a2cae1..4fc770b 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -348,7 +348,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)
 {
-	return RTE_PTR_SUB(mi->buf_addr, sizeof(*mi) + mi->priv_size);
+	return (struct rte_mbuf *) RTE_PTR_SUB(mi->buf_addr, sizeof(*mi) + mi->priv_size);
 }
 
 /**
diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c
index 02699a1..e22ddb3 100644
--- a/lib/librte_mempool/rte_mempool.c
+++ b/lib/librte_mempool/rte_mempool.c
@@ -136,7 +136,7 @@ mempool_add_elem(struct rte_mempool *mp, void *obj, uint32_t obj_idx,
 	obj = (char *)obj + mp->header_size;
 
 	/* set mempool ptr in header */
-	hdr = RTE_PTR_SUB(obj, sizeof(*hdr));
+	hdr = (struct rte_mempool_objhdr *) RTE_PTR_SUB(obj, sizeof(*hdr));
 	hdr->mp = mp;
 
 #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h
index 6d4ce9a..7c966a1 100644
--- a/lib/librte_mempool/rte_mempool.h
+++ b/lib/librte_mempool/rte_mempool.h
@@ -262,13 +262,13 @@ struct rte_mempool {
 /* return the header of a mempool object (internal) */
 static inline struct rte_mempool_objhdr *__mempool_get_header(void *obj)
 {
-	return RTE_PTR_SUB(obj, sizeof(struct rte_mempool_objhdr));
+	return (struct rte_mempool_objhdr *) RTE_PTR_SUB(obj, sizeof(struct rte_mempool_objhdr));
 }
 
 /* return the trailer of a mempool object (internal) */
 static inline struct rte_mempool_objtlr *__mempool_get_trailer(void *obj)
 {
-	return RTE_PTR_SUB(obj, sizeof(struct rte_mempool_objtlr));
+	return (struct rte_mempool_objtlr *) RTE_PTR_SUB(obj, sizeof(struct rte_mempool_objtlr));
 }
 
 /**
-- 
1.9.1

             reply	other threads:[~2015-07-03 12:51 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-03 12:51 Joongi Kim [this message]
2015-07-03 12:51 ` [dpdk-dev] [PATCH 2/2] eal: Fix compilation on C++ Joongi Kim
2015-08-17 15:29   ` Thomas Monjalon
2015-08-17 15:50     ` Thomas Monjalon
2015-11-13  9:35   ` [dpdk-dev] [PATCH 1/2] Revert "eal: fix C++ app build" David Marchand
2015-11-13  9:35     ` [dpdk-dev] [PATCH 2/2] eal: move empty declarations to doc David Marchand
2015-11-23 15:19       ` Thomas Monjalon
2015-08-17 15:22 ` [dpdk-dev] [PATCH 1/2] lib: Fix pointer arithmetic for C++ Thomas Monjalon

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=1435927863-3398-1-git-send-email-joongi@an.kaist.ac.kr \
    --to=joongi@an.kaist.ac.kr \
    --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).