From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from proxy.6wind.com (host.76.145.23.62.rev.coltfrance.com [62.23.145.76]) by dpdk.org (Postfix) with ESMTP id 9E96A5587 for ; Thu, 24 Nov 2016 09:57:01 +0100 (CET) Received: from glumotte.dev.6wind.com (unknown [10.16.0.195]) by proxy.6wind.com (Postfix) with ESMTP id 5DB6526A72; Thu, 24 Nov 2016 09:56:52 +0100 (CET) From: Olivier Matz To: dev@dpdk.org, yuanhan.liu@linux.intel.com Cc: maxime.coquelin@redhat.com, huawei.xie@intel.com, stephen@networkplumber.org Date: Thu, 24 Nov 2016 09:56:34 +0100 Message-Id: <1479977798-13417-2-git-send-email-olivier.matz@6wind.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1479977798-13417-1-git-send-email-olivier.matz@6wind.com> References: <1479977798-13417-1-git-send-email-olivier.matz@6wind.com> Subject: [dpdk-dev] [PATCH 1/5] mbuf: remove const attribute in mbuf read function X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Nov 2016 08:57:02 -0000 There is no good reason to have this const attribute: rte_pktmbuf_read() returns a pointer which is either in a private buffer, or in the mbuf. In the first case, it is clearly not const. In the second case, it is up to the user to check that the mbuf is not shared and that data can be modified. Signed-off-by: Olivier Matz --- lib/librte_mbuf/rte_mbuf.c | 2 +- lib/librte_mbuf/rte_mbuf.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c index 63f43c8..b31958e 100644 --- a/lib/librte_mbuf/rte_mbuf.c +++ b/lib/librte_mbuf/rte_mbuf.c @@ -265,7 +265,7 @@ rte_pktmbuf_dump(FILE *f, const struct rte_mbuf *m, unsigned dump_len) } /* read len data bytes in a mbuf at specified offset (internal) */ -const void *__rte_pktmbuf_read(const struct rte_mbuf *m, uint32_t off, +void *__rte_pktmbuf_read(const struct rte_mbuf *m, uint32_t off, uint32_t len, void *buf) { const struct rte_mbuf *seg = m; diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index ead7c6e..14956f6 100644 --- a/lib/librte_mbuf/rte_mbuf.h +++ b/lib/librte_mbuf/rte_mbuf.h @@ -1576,7 +1576,7 @@ static inline int rte_pktmbuf_is_contiguous(const struct rte_mbuf *m) /** * @internal used by rte_pktmbuf_read(). */ -const void *__rte_pktmbuf_read(const struct rte_mbuf *m, uint32_t off, +void *__rte_pktmbuf_read(const struct rte_mbuf *m, uint32_t off, uint32_t len, void *buf); /** @@ -1599,7 +1599,7 @@ const void *__rte_pktmbuf_read(const struct rte_mbuf *m, uint32_t off, * The pointer to the data, either in the mbuf if it is contiguous, * or in the user buffer. If mbuf is too small, NULL is returned. */ -static inline const void *rte_pktmbuf_read(const struct rte_mbuf *m, +static inline void *rte_pktmbuf_read(const struct rte_mbuf *m, uint32_t off, uint32_t len, void *buf) { if (likely(off + len <= rte_pktmbuf_data_len(m))) -- 2.8.1