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

Simon Goldschmidt simon.k.r.goldschmidt at gmail.com
Tue Nov 5 14:01:28 UTC 2019


On Tue, Nov 5, 2019 at 2:52 PM Tom Rini <trini at konsulko.com> wrote:
>
> On Tue, Nov 05, 2019 at 12:48:19PM +0100, Heinrich Schuchardt wrote:
>
> > sandbox_defconfig does not compile using GCC 9.2.1:
> >
> > net/net.c: In function ‘net_process_received_packet’:
> > net/net.c:1288:23: error: taking address of packed member of ‘struct
> > ip_udp_hdr’ may result in an unaligned pointer value
> > [-Werror=address-of-packed-member]
> >  1288 |    sumptr = (ushort *)&(ip->udp_src);
> >       |                       ^~~~~~~~~~~~~~
> >
> > Avoid the error by using a u8 pointer instead of an u16 pointer and
> > in-lining ntohs().
> >
> > Simplify the checksumming of the last message byte.
> >
> > Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
> > ---
> > v2:
> >       reword commit message
> >       add a comment
> >       simplify checksumming of last byte
>
> If I follow what Simon was saying yesterday, the whole message framing
> is wrong.  The problem isn't that gcc 9.2 is showing a warning, the
> problem is that gcc 9.2 is showing that we have a problem (in terms of
> what can/can't happen in real life networking terms), which you're
> correcting.  Simon, can you please suggest a commit message here if
> you're still not quite happy, as you understand the underlying problem
> well it seems.  Thanks!

Well, we do have an error and GCC 9.2 shows this. I don't know why other
versions don't issue this warning.

This new commit message might still concentrate too much on the GCC version,
but I think it's ok. I just wanted to prevent someone reading this in the
future and taking it as a hint that the attribute 'packed' can be removed
(which in turn might procude bugs on some platforms).

So:
Reviewed-by: Simon Goldschmidt <simon.k.r.goldschmidt at gmail.com>


More information about the U-Boot mailing list