summaryrefslogtreecommitdiff
path: root/lib/librte_mbuf
diff options
context:
space:
mode:
authorAndy Green <andy@warmcat.com>2018-05-22 09:24:32 +0800
committerThomas Monjalon <thomas@monjalon.net>2018-05-22 16:32:36 +0200
commitef5092e16b137fd5e23d19b4b17b32f330d4a4ad (patch)
tree48cccb0ed64eb7270dc942f1a47f75c1b3e2943d /lib/librte_mbuf
parent50f239c9087df9b1a3c14e77f4279c7d5f523138 (diff)
downloaddpdk-ef5092e16b137fd5e23d19b4b17b32f330d4a4ad.zip
dpdk-ef5092e16b137fd5e23d19b4b17b32f330d4a4ad.tar.gz
dpdk-ef5092e16b137fd5e23d19b4b17b32f330d4a4ad.tar.xz
mbuf: avoid implicit demotion in 64-bit arithmetic
GCC 8.1 warned: In function 'rte_validate_tx_offload': 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; ^~ uint64_t inner_l3_offset... /* fields for TX offloading of tunnels */ uint64_t outer_l3_len:9; /**< Outer L3 (IP) Hdr Length. */ uint64_t outer_l2_len:7; /**< Outer L2 (MAC) Hdr Length. */ We want to do the arithmetic entirely in uint64_t space, but with the +=, the rhs type becomes int since the bitfields will fit in int. Elaborate the artithmetic to be u64 = u64 + int + int, so the type of the result is correct to be stored in the u64. Fixes: 4fb7e803eb ("ethdev: add Tx preparation") Cc: stable@dpdk.org Signed-off-by: Andy Green <andy@warmcat.com> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Diffstat (limited to 'lib/librte_mbuf')
-rw-r--r--lib/librte_mbuf/rte_mbuf.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 715f90e..0e89a69 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -2112,7 +2112,11 @@ 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;
+ /* NB: elaborating the addition like this instead of using
+ * += gives the result uint64_t type instead of int,
+ * avoiding compiler warnings on gcc 8.1 at least */
+ inner_l3_offset = inner_l3_offset + 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)