[dpdk-dev] [PATCH v3 18/24] rte_ether.h: explicit cast avoiding truncation warning

Thomas Monjalon thomas at monjalon.net
Sun May 13 19:02:55 CEST 2018


12/05/2018 04:00, Andy Green:
> /projects/lagopus/src/dpdk/build/include/rte_ether.h:213:13:
> warning: conversion from 'int' to 'uint8_t'
> {aka 'unsigned char'} may change value [-Wconversion]
>   addr[0] &= ~ETHER_GROUP_ADDR;
> /* clear multicast bit */
[..]
>  	rte_memcpy(addr, p, ETHER_ADDR_LEN);
> -	addr[0] &= ~ETHER_GROUP_ADDR;       /* clear multicast bit */
> +	addr[0] &= (uint8_t)~ETHER_GROUP_ADDR;       /* clear multicast bit */
>  	addr[0] |= ETHER_LOCAL_ADMIN_ADDR;  /* set local assignment bit */

ETHER_GROUP_ADDR and ETHER_LOCAL_ADMIN_ADDR are defined macros,
they have no type, so I don't understand the need for casting.
And I don't understand why it is not needed for ETHER_LOCAL_ADMIN_ADDR.




More information about the dev mailing list