From: David Marchand <david.marchand@6wind.com>
To: dev@dpdk.org
Cc: olivier.matz@6wind.com
Subject: [dpdk-dev] [PATCH] mbuf: properly cast shared data
Date: Wed, 16 May 2018 13:10:40 +0200 [thread overview]
Message-ID: <1526469040-20860-1-git-send-email-david.marchand@6wind.com> (raw)
Including rte_mbuf.h in C++ triggers the following warning as C++ does not
allow implicit casting of a void *.
In file included from test.cpp:1:0:
x86_64-native-linuxapp-gcc/include/rte_mbuf.h: In function
‘rte_mbuf_ext_shared_info* rte_pktmbuf_ext_shinfo_init_helper(void*, uint16_t*,
rte_mbuf_extbuf_free_callback_t, void*)’:
x86_64-native-linuxapp-gcc/include/rte_mbuf.h:1349:9: error: invalid conversion
from ‘void*’ to ‘rte_mbuf_ext_shared_info*’ [-fpermissive]
shinfo = RTE_PTR_ALIGN_FLOOR(RTE_PTR_SUB(buf_end,
^
Fixes: a53aa2b9f3be ("mbuf: support attaching external buffer")
Signed-off-by: David Marchand <david.marchand@6wind.com>
---
lib/librte_mbuf/rte_mbuf.h | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 4fd9a0d..eab13c6 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -1345,12 +1345,14 @@ rte_pktmbuf_ext_shinfo_init_helper(void *buf_addr, uint16_t *buf_len,
{
struct rte_mbuf_ext_shared_info *shinfo;
void *buf_end = RTE_PTR_ADD(buf_addr, *buf_len);
+ void *addr;
- shinfo = RTE_PTR_ALIGN_FLOOR(RTE_PTR_SUB(buf_end,
- sizeof(*shinfo)), sizeof(uintptr_t));
- if ((void *)shinfo <= buf_addr)
+ addr = RTE_PTR_ALIGN_FLOOR(RTE_PTR_SUB(buf_end, sizeof(*shinfo)),
+ sizeof(uintptr_t));
+ if (addr <= buf_addr)
return NULL;
+ shinfo = (struct rte_mbuf_ext_shared_info *)addr;
shinfo->free_cb = free_cb;
shinfo->fcb_opaque = fcb_opaque;
rte_mbuf_ext_refcnt_set(shinfo, 1);
--
2.7.4
next reply other threads:[~2018-05-16 11:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-16 11:10 David Marchand [this message]
2018-05-18 11:24 ` 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=1526469040-20860-1-git-send-email-david.marchand@6wind.com \
--to=david.marchand@6wind.com \
--cc=dev@dpdk.org \
--cc=olivier.matz@6wind.com \
/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).