On Mon, Jul 01, 2019 at 03:11:12PM +0200, Olivier Matz wrote: > Hi Bruce, > > On Thu, May 16, 2019 at 04:54:57PM +0100, Bruce Richardson wrote: > > 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, > > I'm a bit reserved about this last assumption. The ethernet address > structure may be used in a private structure, whose alignment is 1. Are > we sure that there is no (funny) protocol that carries unaligned > ethernet addresses? > > Shouldn't we change the definition of unaligned_uint16_t instead? > Or change the rte_is_broadcast_ether_addr() function? >
We could, but I believe the correct behaviour is to make the addresses always 2-byte aligned, unless someone actually has a real-world case where there is a protocol that doesn't have the data 2-byte aligned. /Bruce