On 05/14/2018 01:02 AM, Thomas Monjalon wrote:
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.
Both of those manifest constants are 0x1.
But ~ETHER_GROUP_ADDR is a "big number" in an int.
The compiler notices a definite truncation if you try to put 0xfffffffe
in a uint8_t and complains.
If you try to put 0x01 in a uint8_t, the compiler feels it was OK.
-Andy