From: David Marchand Date: Wed, 16 May 2018 11:10:40 +0000 (+0200) Subject: mbuf: fix C++ build on void pointer cast X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=a2ff2827dc84b3acbb2270c49b4b0a82a09712cb;p=dpdk.git mbuf: fix C++ build on void pointer cast 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: 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*)’: 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 --- diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index 4fd9a0d9e1..eab13c6bf8 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);