From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.warmcat.com (mail.warmcat.com [163.172.24.82]) by dpdk.org (Postfix) with ESMTP id F33F77CFD for ; Thu, 17 May 2018 15:50:31 +0200 (CEST) From: Andy Green To: dev@dpdk.org Date: Thu, 17 May 2018 21:50:27 +0800 Message-ID: <152656502764.46638.10703928515643057512.stgit@localhost.localdomain> In-Reply-To: <152656480225.46638.3271983577765861155.stgit@localhost.localdomain> References: <152656480225.46638.3271983577765861155.stgit@localhost.localdomain> User-Agent: StGit/unknown-version Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: [dpdk-dev] [PATCH v5 19/21] 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 13:50:32 -0000 /projects/lagopus/src/dpdk/build/include/rte_mbuf.h: In function 'rte_pktmbuf_detach': /projects/lagopus/src/dpdk/build/include/rte_mbuf.h: 1583:17: warning: conversion from 'uint32_t' {aka 'unsigned int'} to 'uint16_t' {aka 'short unsigned int'} may change value [-Wconversion] m->priv_size = priv_size; ^~~~~~~~~ /projects/lagopus/src/dpdk/build/include/rte_mbuf.h: In function 'rte_pktmbuf_prepend': /projects/lagopus/src/dpdk/build/include/rte_mbuf.h: 1908:17: warning: conversion from 'int' to 'uint16_t' {aka 'short unsigned int'} may change value [-Wconversion] m->data_off -= len; ^~~ /projects/lagopus/src/dpdk/build/include/rte_mbuf.h: In function 'rte_pktmbuf_adj': /projects/lagopus/src/dpdk/build/include/rte_mbuf.h: 1969:17: warning: conversion from 'int' to 'uint16_t' {aka 'short unsigned int'} may change value [-Wconversion] m->data_off += len; ^~~ /projects/lagopus/src/dpdk/build/include/rte_mbuf.h: In function 'rte_pktmbuf_chain': /projects/lagopus/src/dpdk/build/include/rte_mbuf.h: 2082:19: warning: conversion from 'int' to 'uint16_t' {aka 'short unsigned int'} may change value [-Wconversion] head->nb_segs += tail->nb_segs; ^~~~ /projects/lagopus/src/dpdk/build/include/rte_mbuf.h: In function 'rte_validate_tx_offload': /projects/lagopus/src/dpdk/build/include/rte_mbuf.h: 2112:19: warning: conversion to 'uint64_t' {aka 'long unsigned int'} from 'int' may change the sign of the result [-Wsign-conversion] inner_l3_offset += m->outer_l2_len + m->outer_l3_len; ^~ /projects/lagopus/src/dpdk/build/include/rte_mbuf.h: In function 'rte_pktmbuf_linearize': /projects/lagopus/src/dpdk/build/include/rte_mbuf.h: 1873:32: warning: conversion to 'int' from 'uint32_t' {aka 'unsigned int'} may change the sign of the result [-Wsign-conversion] #define rte_pktmbuf_pkt_len(m) ((m)->pkt_len) ^ /projects/lagopus/src/dpdk/build/include/rte_mbuf.h: 2166:13: note: in expansion of macro 'rte_pktmbuf_pkt_len' copy_len = rte_pktmbuf_pkt_len(mbuf) - rte_pktmbuf_data_len(mbuf); ^~~~~~~~~~~~~~~~~~~ /projects/lagopus/src/dpdk/build/include/rte_mbuf.h: 2180:51: warning: conversion to 'size_t' {aka 'long unsigned int'} from 'int' may change the sign of the result [-Wsign-conversion] rte_memcpy(buffer, rte_pktmbuf_mtod(m, char *), seg_len); ^~~~~~~ Signed-off-by: Andy Green --- lib/librte_mbuf/rte_mbuf.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index 7849192c6..4eddf238e 100644 --- a/lib/librte_mbuf/rte_mbuf.h +++ b/lib/librte_mbuf/rte_mbuf.h @@ -1569,7 +1569,8 @@ __rte_pktmbuf_free_direct(struct rte_mbuf *m) static inline void rte_pktmbuf_detach(struct rte_mbuf *m) { struct rte_mempool *mp = m->pool; - uint32_t mbuf_size, buf_len, priv_size; + uint32_t mbuf_size, buf_len; + uint16_t priv_size; if (RTE_MBUF_HAS_EXTBUF(m)) __rte_pktmbuf_free_extbuf(m); @@ -1905,7 +1906,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); @@ -1966,7 +1967,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 +2080,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 +2110,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 +2156,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 +2171,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;