[dpdk-dev] [PATCH v3 5/6] net/ether: mark ethernet addresses as being 2-byte aligned

Andrew Rybchenko arybchenko at solarflare.com
Wed Jun 5 11:04:20 CEST 2019

On 6/5/19 4:08 AM, Stephen Hemminger wrote:
> From: Bruce Richardson <bruce.richardson at intel.com>
> When including the rte_ether.h header in applications with warnings
> enabled, a warning was given because of the assumption of 2-byte alignment
> of ethernet addresses when processing them.
> .../include/rte_ether.h:149:2: warning: converting a packed ‘const
>    struct ether_addr’ pointer (alignment 1) to a ‘unaligned_uint16_t’
>    {aka ‘const short unsigned int’} pointer (alignment 2) may result in
>    an unaligned pointer value [-Waddress-of-packed-member]
> 149 |  const unaligned_uint16_t *ea_words = (const unaligned_uint16_t *)ea;
>      |  ^~~~~
> Since ethernet addresses should always be aligned on a two-byte boundary,
> we can just inform the compiler of this assumption to remove the warnings
> and allow us to always access the addresses using 16-bit operations.
> Signed-off-by: Bruce Richardson <bruce.richardson at intel.com>
> Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>

Reviewed-by: Andrew Rybchenko <arybchenko at solarflare.com>

More information about the dev mailing list