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>