]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Use __builtin_unreachable(). [skip ci]
authorDenis Ovsienko <[email protected]>
Sun, 15 Aug 2021 09:54:50 +0000 (10:54 +0100)
committerDenis Ovsienko <[email protected]>
Sun, 15 Aug 2021 10:12:00 +0000 (11:12 +0100)
Same as in libpcap.

diag-control.h
extract.h

index b7ef01fc46a150089c5a5d6920b6b2b4b186fa44..3eb6bcaaf02094c5ac8c834339e81ec8b2d6238f 100644 (file)
 #define DIAG_ON_C11_EXTENSIONS
 #endif
 
+/*
+ * GCC needs this on AIX for longjmp().
+ */
+#if ND_IS_AT_LEAST_GNUC_VERSION(5,1)
+  /*
+   * Beware that the effect of this builtin is more than just squelching the
+   * warning! GCC trusts it enough for the process to segfault if the control
+   * flow reaches the builtin (an infinite empty loop in the same context would
+   * squelch the warning and ruin the process too, albeit in a different way).
+   * So please remember to use this very carefully.
+   */
+  #define ND_UNREACHABLE __builtin_unreachable();
+#else
+  #define ND_UNREACHABLE
+#endif
+
 #endif /* _diag_control_h */
index 510b4a15f4ac5f9c1bca428feac464da53a1dfc4..c355c4d97be554c804cdf51fbb079202ffb1a84b 100644 (file)
--- a/extract.h
+++ b/extract.h
@@ -37,6 +37,7 @@
  */
 #include "funcattrs.h"
 #include "netdissect.h"
+#include "diag-control.h"
 
 /*
  * If we have versions of GCC or Clang that support an __attribute__
@@ -585,7 +586,7 @@ nd_trunc_longjmp(netdissect_options *ndo)
         * XL C that the function is noreturn, but GCC remains unaware of that and
         * yields a "'noreturn' function does return" warning.
         */
-       while (1);
+       ND_UNREACHABLE
 #endif /* _AIX */
 }