1
0
Fork 0
mirror of https://passt.top/passt synced 2025-06-15 03:45:34 +02:00

udp: Replace pragma to ignore bogus stringop-overread warning with workaround

Commit c318ffcb4c ("udp: Ignore bogus -Wstringop-overread for
write() from gcc 12.1") uses a gcc pragma to ignore a bogus warning,
which started appearing on gcc 12.1 (aarch64 and x86_64) due to:
  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103483

...but gcc 12.2 has the same issue. Not just that: if LTO is enabled,
the pragma itself is ignored (this wasn't the case with gcc 12.1),
because of:
  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80922

Drop the pragma, and assign a frame (in the networking sense) pointer
from the offset of the Ethernet header in the buffer, then pass it to
write() and pcap(), so that gcc doesn't obsess anymore with the fact
that an Ethernet header is 14 bytes and we're sending more than that.

Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
Stefano Brivio 2022-09-28 20:45:55 +02:00
parent 505a33e9f9
commit 5290b6f13e
2 changed files with 18 additions and 31 deletions

23
util.h
View file

@ -96,29 +96,6 @@ void trace_init(int enable);
(void *)(arg)); \
} while (0)
#ifdef __has_warning
# if __has_warning("-Wstringop-overread")
# define PRAGMA_STRINGOP_OVERREAD_IGNORE \
_Pragma("GCC diagnostic ignored \"-Wstringop-overread\"")
# define PRAGMA_STRINGOP_OVERREAD_IGNORE_POP \
_Pragma("GCC diagnostic pop")
# else
# define PRAGMA_STRINGOP_OVERREAD_IGNORE
# define PRAGMA_STRINGOP_OVERREAD_IGNORE_POP
# endif
#else
# if defined(__GNUC__) && __GNUC__ >= 11
# define PRAGMA_STRINGOP_OVERREAD_IGNORE \
_Pragma("GCC diagnostic ignored \"-Wstringop-overread\"")
# define PRAGMA_STRINGOP_OVERREAD_IGNORE_POP \
_Pragma("GCC diagnostic pop")
# else
# define PRAGMA_STRINGOP_OVERREAD_IGNORE
# define PRAGMA_STRINGOP_OVERREAD_IGNORE_POP
# endif
#endif
#if __BYTE_ORDER == __BIG_ENDIAN
#define L2_BUF_ETH_IP4_INIT \
{ \