[dpdk-stable] [dpdk-dev] [PATCH] net: fix compilation with pedantic enabled

Ferruh Yigit ferruh.yigit at intel.com
Tue Jul 21 02:05:57 CEST 2020


On 7/16/2020 1:12 PM, Raslan Darawsheh wrote:
> when trying to compile rte_mpls with pedantic enabled,
> it will complain about bit field defintion.
> error: type of bit-field 'bs' is a GCC extension [-Werror=pedantic]
> error: type of bit-field 'tc' is a GCC extension [-Werror=pedantic]
> error: type of bit-field 'tag_lsb' is a GCC extension [-Werror=pedantic]
'
I tried to reproduce by adding to '-pedantic' to 'rte_net.c' (which uses
'rte_mpls.h') but not able to get the warning. Is this happen with specific
version of the compiler?

> 
> This fixes the compilation error.
> 
> Fixes: e480cf487a0d ("net: add MPLS header structure")
> Cc: olivier.matz at 6wind.com
> Cc: stable at dpdk.org
> 
> Signed-off-by: Raslan Darawsheh <rasland at mellanox.com>
> ---
>  lib/librte_net/rte_mpls.h | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/lib/librte_net/rte_mpls.h b/lib/librte_net/rte_mpls.h
> index db91707..ecd1f64 100644
> --- a/lib/librte_net/rte_mpls.h
> +++ b/lib/librte_net/rte_mpls.h
> @@ -24,13 +24,13 @@ extern "C" {
>  struct rte_mpls_hdr {
>  	uint16_t tag_msb;   /**< Label(msb). */
>  #if RTE_BYTE_ORDER == RTE_BIG_ENDIAN
> -	uint8_t tag_lsb:4;  /**< Label(lsb). */
> -	uint8_t tc:3;       /**< Traffic class. */
> -	uint8_t bs:1;       /**< Bottom of stack. */
> +	uint32_t tag_lsb:4;  /**< Label(lsb). */
> +	uint32_t tc:3;       /**< Traffic class. */
> +	uint32_t bs:1;       /**< Bottom of stack. */
>  #else
> -	uint8_t bs:1;       /**< Bottom of stack. */
> -	uint8_t tc:3;       /**< Traffic class. */
> -	uint8_t tag_lsb:4;  /**< label(lsb) */
> +	uint32_t bs:1;       /**< Bottom of stack. */
> +	uint32_t tc:3;       /**< Traffic class. */
> +	uint32_t tag_lsb:4;  /**< label(lsb) */
>  #endif
>  	uint8_t  ttl;       /**< Time to live. */
>  } __rte_packed;

The struct size keeps same after change, do you know if this behavior is part of
standard and guaranteed?


More information about the stable mailing list