On Thu, 5 Mar 2026 at 12:18, Thomas Huth <[email protected]> wrote: > > On 05/03/2026 12.18, Peter Maydell wrote:
> > - ip = (struct ip_header*)eth_payload_data; > > + /* > > + * It would be more natural to write this as > > + * ip = (struct ip_header *)eth_payload_data; > > + * (the IP header is at the start of the ethernet payload). > > + * However, writing it that way triggers a GCC bug where an > > + * interaction between -fsanitize=address and > > -Wstringop-overflow > > + * results in a false-positive stringop-overflow warning that > > is > > + * only emitted when the address sanitizer is enabled: > > + * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114494 > > + * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99673 > > + * So we work around this by writing the expression in an > > equivalent > > + * way that doesn't run into this bug. > > + */ > > + ip = (struct ip_header *)saved_buffer + ETH_HLEN; > > Uh, isn't that a different pointer location? I mean, this first casts to > struct ip_header*, then does the math on that pointer type, i.e. it adds > ETH_HLEN * sizeof(struct ip_header) bytes? > > I think you need this instead: > > ip = (struct ip_header *)(saved_buffer + ETH_HLEN); > > But is the warning still gone in that case? Rats, you're right -- good catch. And no, if we fix the expression then the warning comes back. I guess we'll have to do it with a warning-disabling pragma :-( -- PMM
