From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f193.google.com (mail-wr0-f193.google.com [209.85.128.193]) by dpdk.org (Postfix) with ESMTP id 561E51B21F for ; Wed, 16 May 2018 13:10:46 +0200 (CEST) Received: by mail-wr0-f193.google.com with SMTP id a12-v6so452661wrn.13 for ; Wed, 16 May 2018 04:10:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=wCGu1a6FI2wpob3CThCSKEf6WmcixxrQSYdCkEN12oA=; b=dKYz0dFP8xYgE+d0tcjqGR4VDuyHanldAOHnEE1u4WBEbJkEihrx4Yll9d1TQHo1yE FB0h/kUtSa6ZlfZ7Bp0oaJp/mm0mpuWYLa2pepbXYGhdqhVILkJljuh/Ium7vUprqxnN fatCiMCGHGqyQ9AjqHUJkJ2UfLRN7Aqp7tUaBlA1uKi38kvFPLin2OLoCG/zU3APEFdi lF0YkaWg2rwt49kIuqpXz2T6aMrXsirBTISwkEC3e0YQjqbtVQ/8nBJler7CXWkX2EQV YpoBDRWLvtLojyCs/53QvHaOAGSEJQ/4VXL1G0v/0sd5YBVOInpbZVdIbJwGga/BvhGp zpyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=wCGu1a6FI2wpob3CThCSKEf6WmcixxrQSYdCkEN12oA=; b=W1Rqwe/vF+LnulFhFv8IprYEtTSiRnrRACKD3SPy+bABw1kZWqrvdNSkoaZT2zAIAo wZuaU09G9pbc/Of/pxPG3S6q/QQcDEJq4A0BfAKG7nb+L0N81hXpWCc4Rvg/ZHrPwqfm pkOFPCT9cs0OuQFTDOHjAm/jkqK/PHKpwyTbpSqQuFkV8Pfj0AU6TnQ+IWt4xcU1aKo4 IbX4aSIzqZWGGsDO8hOcnA9/ejCjBzvZ4bMRemJ/IzeGomR1LQUdn0nyWXv8azulhwH8 VTJsZRdcsvIsqQEm8hwM40moW6NrCaPXnBgPGzfb6ooWOHRFVLCamIMjxf4Qvhu/oR6c EXfQ== X-Gm-Message-State: ALKqPwfZxnpINZg+TBhKWifGQyI6khCAi9NjUff0DQ2cbOKgMjmV7UM1 F0Tf8eWO3L1n5JXB1+9zUBxjXhiW/PM= X-Google-Smtp-Source: AB8JxZpYfGgLGlrLrljGrWuF+UKOalGpk+5K1s0YnkIgB1rrWuj54NjjxPy346zes8oQ52ZAWFIvXA== X-Received: by 2002:adf:86b2:: with SMTP id 47-v6mr433895wrx.256.1526469045305; Wed, 16 May 2018 04:10:45 -0700 (PDT) Received: from 6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id c21-v6sm3712541wre.81.2018.05.16.04.10.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 16 May 2018 04:10:44 -0700 (PDT) From: David Marchand To: dev@dpdk.org Cc: olivier.matz@6wind.com Date: Wed, 16 May 2018 13:10:40 +0200 Message-Id: <1526469040-20860-1-git-send-email-david.marchand@6wind.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] mbuf: properly cast shared data X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 May 2018 11:10:46 -0000 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 --- 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