[dpdk-dev] [PATCH v5 13/21] rte_ip.h: cast input to bswap16 to be uint16

Andy Green andy at warmcat.com
Thu May 17 15:49:57 CEST 2018


In file included from /projects/lagopus/src/dpdk/
build/include/rte_ether.h:24,
                 from /projects/lagopus/src/dpdk/
build/include/rte_ethdev.h:158,
                 from ./dpdk/worker.c:90:
/projects/lagopus/src/dpdk/build/include/rte_ip.h:
In function 'rte_raw_cksum_mbuf':
/projects/lagopus/src/dpdk/build/include/rte_ip.h:
225:22: warning: conversion from 'uint32_t'
{aka 'unsigned int'} to 'uint16_t' {aka 'short
unsigned int'} may change value [-Wconversion]
    tmp = rte_bswap16(tmp);
                      ^~~
/projects/lagopus/src/dpdk/build/include/
rte_byteorder.h:53:25: note: in definition of
macro 'rte_bswap16'
        rte_arch_bswap16(x)))
                         ^

Signed-off-by: Andy Green <andy at warmcat.com>
---
 lib/librte_net/rte_ip.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_net/rte_ip.h b/lib/librte_net/rte_ip.h
index f32684c66..b46a0c717 100644
--- a/lib/librte_net/rte_ip.h
+++ b/lib/librte_net/rte_ip.h
@@ -222,7 +222,7 @@ rte_raw_cksum_mbuf(const struct rte_mbuf *m, uint32_t off, uint32_t len,
 	for (;;) {
 		tmp = __rte_raw_cksum(buf, seglen, 0);
 		if (done & 1)
-			tmp = rte_bswap16(tmp);
+			tmp = rte_bswap16((uint16_t)tmp);
 		sum += tmp;
 		done += seglen;
 		if (done == len)



More information about the dev mailing list