From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 150A21D9E for ; Thu, 17 May 2018 12:58:38 +0200 (CEST) X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 May 2018 03:58:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,410,1520924400"; d="scan'208";a="41702492" Received: from bricha3-mobl.ger.corp.intel.com ([10.237.221.55]) by orsmga007.jf.intel.com with SMTP; 17 May 2018 03:58:35 -0700 Received: by (sSMTP sendmail emulation); Thu, 17 May 2018 11:58:35 +0100 Date: Thu, 17 May 2018 11:58:34 +0100 From: Bruce Richardson To: Andy Green Cc: dev@dpdk.org Message-ID: <20180517105834.GE22048@bricha3-MOBL.ger.corp.intel.com> References: <152627436523.53156.4398253089110011263.stgit@localhost.localdomain> <152627463294.53156.15245682101037939156.stgit@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <152627463294.53156.15245682101037939156.stgit@localhost.localdomain> Organization: Intel Research and Development Ireland Ltd. User-Agent: Mutt/1.9.4 (2018-02-28) Subject: Re: [dpdk-dev] [PATCH v4 13/23] rte_mbuf.h: explicit casts to uint16 to avoid warnings 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 10:58:39 -0000 On Mon, May 14, 2018 at 01:10:32PM +0800, Andy Green wrote: > Signed-off-by: Andy Green > --- > lib/librte_mbuf/rte_mbuf.h | 15 ++++++++------- > 1 file changed, 8 insertions(+), 7 deletions(-) > > diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h > index 169f3d3b0..3cd76abbc 100644 > --- a/lib/librte_mbuf/rte_mbuf.h > +++ b/lib/librte_mbuf/rte_mbuf.h > @@ -1580,7 +1580,7 @@ static inline void rte_pktmbuf_detach(struct rte_mbuf *m) > mbuf_size = (uint32_t)sizeof(struct rte_mbuf) + priv_size; > buf_len = rte_pktmbuf_data_room_size(mp); > > - m->priv_size = priv_size; > + m->priv_size = (uint16_t)priv_size; > m->buf_addr = (char *)m + mbuf_size; > m->buf_iova = rte_mempool_virt2iova(m) + mbuf_size; > m->buf_len = (uint16_t)buf_len; I think a better fix for this is to change priv_size to be uint16_t. There is no reason for it to be a 32-bit value. > @@ -1905,7 +1905,7 @@ static inline char *rte_pktmbuf_prepend(struct rte_mbuf *m, > if (unlikely(len > rte_pktmbuf_headroom(m))) > return NULL; > > - m->data_off -= len; > + m->data_off = (uint16_t)(m->data_off - len); > m->data_len = (uint16_t)(m->data_len + len); > m->pkt_len = (m->pkt_len + len); > What is the error message here? The cast isn't wrong, it just seems like we shouldn't need it. I suppose it's implicit promotion being done in the subtraction operation. > @@ -1966,7 +1966,7 @@ static inline char *rte_pktmbuf_adj(struct rte_mbuf *m, uint16_t len) > return NULL; > > m->data_len = (uint16_t)(m->data_len - len); > - m->data_off += len; > + m->data_off = (uint16_t)(m->data_off + len); > m->pkt_len = (m->pkt_len - len); > return (char *)m->buf_addr + m->data_off; > } > @@ -2079,7 +2079,7 @@ static inline int rte_pktmbuf_chain(struct rte_mbuf *head, struct rte_mbuf *tail > cur_tail->next = tail; > > /* accumulate number of segments and total length. */ > - head->nb_segs += tail->nb_segs; > + head->nb_segs = (uint16_t)(head->nb_segs + tail->nb_segs); > head->pkt_len += tail->pkt_len; > > /* pkt_len is only set in the head */ > @@ -2109,7 +2109,8 @@ rte_validate_tx_offload(const struct rte_mbuf *m) > return 0; > > if (ol_flags & PKT_TX_OUTER_IP_CKSUM) > - inner_l3_offset += m->outer_l2_len + m->outer_l3_len; > + inner_l3_offset += (unsigned int)(m->outer_l2_len + > + m->outer_l3_len); > > /* Headers are fragmented */ > if (rte_pktmbuf_data_len(m) < inner_l3_offset + m->l3_len + m->l4_len) > @@ -2154,7 +2155,7 @@ rte_validate_tx_offload(const struct rte_mbuf *m) > static inline int > rte_pktmbuf_linearize(struct rte_mbuf *mbuf) > { > - int seg_len, copy_len; > + size_t seg_len, copy_len; > struct rte_mbuf *m; > struct rte_mbuf *m_next; > char *buffer; > @@ -2169,7 +2170,7 @@ rte_pktmbuf_linearize(struct rte_mbuf *mbuf) > return -1; > > buffer = rte_pktmbuf_mtod_offset(mbuf, char *, mbuf->data_len); > - mbuf->data_len = (uint16_t)(mbuf->pkt_len); > + mbuf->data_len = (uint16_t)mbuf->pkt_len; > > /* Append data from next segments to the first one */ > m = mbuf->next; >