aboutgitcodebugslistschat
path: root/util.h
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2022-05-19 13:07:33 +0200
committerStefano Brivio <sbrivio@redhat.com>2022-05-19 16:27:20 +0200
commitc318ffcb4c932752cd1f48bf5d1b0268f58895bd (patch)
tree30f28814818a2ef35a424379749732b5f32bef32 /util.h
parent3d4c2a44a69bba90f3ca70ba998b92ce892bbcd8 (diff)
downloadpasst-c318ffcb4c932752cd1f48bf5d1b0268f58895bd.tar
passt-c318ffcb4c932752cd1f48bf5d1b0268f58895bd.tar.gz
passt-c318ffcb4c932752cd1f48bf5d1b0268f58895bd.tar.bz2
passt-c318ffcb4c932752cd1f48bf5d1b0268f58895bd.tar.lz
passt-c318ffcb4c932752cd1f48bf5d1b0268f58895bd.tar.xz
passt-c318ffcb4c932752cd1f48bf5d1b0268f58895bd.tar.zst
passt-c318ffcb4c932752cd1f48bf5d1b0268f58895bd.zip
udp: Ignore bogus -Wstringop-overread for write() from gcc 12.1
With current OpenSUSE Tumbleweed on aarch64 (gcc-12-1.3.aarch64) and on x86_64 (gcc-12-1.4.x86_64), but curiously not on armv7hl (gcc-12-1.3.armv7hl), gcc warns about using the _pointer_ to the 802.3 header to write the whole frame to the tap descriptor: reading between 62 and 4294967357 bytes from a region of size 14 which is bogus: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103483 Probably declaring udp_sock_fill_data_v{4,6}() as noinline would "fix" this, but that's on the data path, so I'd rather not. Use a gcc pragma instead. Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'util.h')
-rw-r--r--util.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/util.h b/util.h
index f85a87a..6f2c702 100644
--- a/util.h
+++ b/util.h
@@ -102,6 +102,29 @@ enum {
(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 \
{ \