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 5CB214CA5 for ; Thu, 17 May 2018 10:30:25 +0200 (CEST) Received: from core.dev.6wind.com (unknown [10.0.0.1]) by proxy.6wind.com (Postfix) with ESMTPS id 03D1B178D6C; Thu, 17 May 2018 10:27:15 +0200 (CEST) Received: from [10.16.0.195] (helo=6wind.com) by core.dev.6wind.com with smtp (Exim 4.84_2) (envelope-from ) id 1fJEId-0002cu-7P; Thu, 17 May 2018 10:30:12 +0200 Received: by 6wind.com (sSMTP sendmail emulation); Thu, 17 May 2018 10:30:11 +0200 Date: Thu, 17 May 2018 10:30:11 +0200 From: Olivier Matz To: Andy Green Cc: dev@dpdk.org Message-ID: <20180517083011.3qskkxkqgdg2i6jv@glumotte.dev.6wind.com> References: <152627436523.53156.4398253089110011263.stgit@localhost.localdomain> <152627461281.53156.1973319644929375310.stgit@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <152627461281.53156.1973319644929375310.stgit@localhost.localdomain> User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [dpdk-dev] [PATCH v4 09/23] rte_mbuf.h: explicit casts for int16 to uint16 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: Thu, 17 May 2018 08:30:25 -0000 On Mon, May 14, 2018 at 01:10:12PM +0800, Andy Green wrote: > differences to the atomic16 are signed, but the > atomic16 itself is unsigned. It needs to be > made explicit with casts. > > Signed-off-by: Andy Green > --- > lib/librte_mbuf/rte_mbuf.h | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h > index a2a37a311..c214f1945 100644 > --- a/lib/librte_mbuf/rte_mbuf.h > +++ b/lib/librte_mbuf/rte_mbuf.h > @@ -806,7 +806,7 @@ rte_mbuf_refcnt_read(const struct rte_mbuf *m) > static inline void > rte_mbuf_refcnt_set(struct rte_mbuf *m, uint16_t new_value) > { > - rte_atomic16_set(&m->refcnt_atomic, new_value); > + rte_atomic16_set(&m->refcnt_atomic, (int16_t)new_value); > } > > /* internal */ > @@ -837,8 +837,8 @@ rte_mbuf_refcnt_update(struct rte_mbuf *m, int16_t value) > */ > if (likely(rte_mbuf_refcnt_read(m) == 1)) { > ++value; > - rte_mbuf_refcnt_set(m, value); > - return value; > + rte_mbuf_refcnt_set(m, (uint16_t)value); > + return (uint16_t)value; > } > > return __rte_mbuf_refcnt_update(m, value); > @@ -909,7 +909,7 @@ static inline void > rte_mbuf_ext_refcnt_set(struct rte_mbuf_ext_shared_info *shinfo, > uint16_t new_value) > { > - rte_atomic16_set(&shinfo->refcnt_atomic, new_value); > + rte_atomic16_set(&shinfo->refcnt_atomic, (int16_t)new_value); > } > > /** > @@ -929,8 +929,8 @@ rte_mbuf_ext_refcnt_update(struct rte_mbuf_ext_shared_info *shinfo, > { > if (likely(rte_mbuf_ext_refcnt_read(shinfo) == 1)) { > ++value; > - rte_mbuf_ext_refcnt_set(shinfo, value); > - return value; > + rte_mbuf_ext_refcnt_set(shinfo, (uint16_t)value); > + return (uint16_t)value; > } > > return (uint16_t)rte_atomic16_add_return(&shinfo->refcnt_atomic, value); > Looking at the API of functions, I think there are some inconsistencies: static inline void rte_mbuf_refcnt_set(struct rte_mbuf *m, uint16_t new_value) /* internal */ static inline uint16_t __rte_mbuf_refcnt_update(struct rte_mbuf *m, int16_t value) static inline uint16_t rte_mbuf_refcnt_update(struct rte_mbuf *m, int16_t value) For next version, I think we should change it to be int16_t everywhere, to avoid some of the explicit casts you are introducing. If we want it for 18.05: Acked-by: Olivier Matz