[U-Boot] [PATCH 1/1] net: avoid address-of-packed-member error

Simon Goldschmidt simon.k.r.goldschmidt at gmail.com
Mon Nov 4 21:21:14 UTC 2019

Tom Rini <trini at konsulko.com> schrieb am Mo., 4. Nov. 2019, 22:15:

> On Mon, Nov 04, 2019 at 09:28:51PM +0100, Simon Goldschmidt wrote:
> > Am 04.11.2019 um 20:34 schrieb Heinrich Schuchardt:
> > > struct ip_udp_hdr is naturally packed. There is no point in adding a
> > > __packed attribute. With the attribute the network stack does not
> compile
> > > using GCC 9.2.1:
> >
> > Is this commit message correct? In lwIP, we *do* need to pack all these
> > network header structs as they can come in unaligned. Especially the IP
> > header is normally 16-bit aligned if the incoming Ethernet frame is
> 32-bit
> > aligned (which is a must for many DMA engines).
> >
> > This is also the reason why the below code works, I guess: it is rarely
> > totally unaligned, but nearly always at least 16-bit aligned, so
> > dereferencing the checksum pointer as aligned u16 just works.
> >
> > Nevertheless, the code is formally wrong and your patch is correct. I
> just
> > don't like the commit message saying 'packed' is not required.
> Perhaps we should fix the underlying code problem then?  Or does that
> men "rewrite the whole file" ?

This patch fixes the code problem. If there are more problems: any
assignment to an u16 pointer from an address of a packed struct issues a
warning (provided that appropriate warning settings are used). If we fix
all of these warnings (e.g. like we do here, by using alignment agnostic
byte accesses), we should be good.

I just think the misleading commit message should be fixed before giving my



More information about the U-Boot mailing list