]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Make illumos build warning-free. [skip appveyor]
authorDenis Ovsienko <[email protected]>
Tue, 27 Feb 2024 18:33:24 +0000 (18:33 +0000)
committerDenis Ovsienko <[email protected]>
Thu, 29 Aug 2024 11:38:31 +0000 (12:38 +0100)
As it turns out, the root cause of Clang warnings about tcpdump.c on
illumos has to do with illumos headers rather than tcpdump.  Until the
bug fix is in place and has propagated well into illumos distributions,
use a workaround: add a new pair of diagnostic control macros for Clang
only and on illumos wrap the "offending" lines with it.

(cherry picked from commit 68761b465f6db19d5f5da9481322c74629c6e7f9)

CHANGES
build.sh
diag-control.h
tcpdump.c

diff --git a/CHANGES b/CHANGES
index ff6a47be92e6d08b8c2f57617b5bf37b8938ccf4..63042be9d64160da80a943a5c7557f54e7b319e0 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -116,6 +116,7 @@ DayOfTheWeek, Month DD, YYYY / The Tcpdump Group
       Autoconf: don't use egrep, use $EGREP.
       Autoconf: check for gethostbyaddr(), not gethostbyname().
       Autoconf, CMake: search for gethostbyaddr() in libnetwork.
+      Make illumos build warning-free.
     Documentation:
       Fixed errors in doc/README.Win32.md and renamed it to README.windows.md.
       Make various improvements to the man page.
index 6f70131c063502f6fec38cf44b7fb2a99392d3fb..d12383f4be42e98d00b4b22c626b7fbb167ff829 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -35,13 +35,7 @@ print_cc_version
 # later warnings in the same matrix subset trigger an error.
 
 case `cc_id`/`os_id` in
-clang-*/SunOS-5.11)
-    # (Clang 9 on OpenIndiana, Clang 11 on OmniOS)
-    # tcpdump.c:2312:51: warning: this function declaration is not a prototype
-    #   [-Wstrict-prototypes]
-    # tcpdump.c:2737:11: warning: this function declaration is not a prototype
-    #   [-Wstrict-prototypes]
-    [ "`uname -o`" = illumos ] && TCPDUMP_TAINTED=yes
+*)
     ;;
 suncc-5.1[45]/SunOS-5.11)
     # Various E_STATEMENT_NOT_REACHED and E_DEPRECATED_ATT warnings.
index 73c745d12c25cfbb8392cce429714e2a07004996..5e5a2dfe461afcc87835f29a916cdb2cbf12f3e6 100644 (file)
     #define DIAG_ON_C11_EXTENSIONS \
       DIAG_DO_PRAGMA(clang diagnostic pop)
   #endif
+
+  /*
+   * When Clang correctly detects an old-style function prototype after
+   * preprocessing, the warning can be irrelevant to this source tree because
+   * the prototype comes from a system header macro.
+   */
+  #if ND_IS_AT_LEAST_CLANG_VERSION(5,0)
+    #define DIAG_OFF_STRICT_PROTOTYPES \
+      DIAG_DO_PRAGMA(clang diagnostic push) \
+      DIAG_DO_PRAGMA(clang diagnostic ignored "-Wstrict-prototypes")
+    #define DIAG_ON_STRICT_PROTOTYPES \
+      DIAG_DO_PRAGMA(clang diagnostic pop)
+  #endif
 #elif ND_IS_AT_LEAST_GNUC_VERSION(4,2)
   /* GCC apparently doesn't complain about ORing enums together. */
 
   /*
    * GCC supports -Wc99-c11-compat since version 5.1.0, but the warning does
    * not trigger for now, so let's just leave it be.
+   *
+   * GCC does not currently generate any -Wstrict-prototypes warnings that
+   * would need silencing as is done for Clang above.
    */
 #endif
 
 #ifndef DIAG_ON_C11_EXTENSIONS
 #define DIAG_ON_C11_EXTENSIONS
 #endif
+#ifndef DIAG_OFF_STRICT_PROTOTYPES
+#define DIAG_OFF_STRICT_PROTOTYPES
+#endif
+#ifndef DIAG_ON_STRICT_PROTOTYPES
+#define DIAG_ON_STRICT_PROTOTYPES
+#endif
 #ifndef ND_UNREACHABLE
 #define ND_UNREACHABLE
 #endif
index 92b76c4017c2f75bf62594083b115655f6a63245..a4cdbe076d42c2770ea2585b6f5ec202c31f4b45 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -2300,7 +2300,21 @@ DIAG_ON_WARN_UNUSED_RESULT
 #endif
        /* Cooperate with nohup(1) */
 #ifndef _WIN32
+       /*
+        * In illumos /usr/include/sys/iso/signal_iso.h causes Clang to
+        * generate a -Wstrict-prototypes warning here, see [1].  The
+        * __illumos__ macro is available since at least GCC 11 and Clang 13,
+        * see [2].
+        * 1: https://www.illumos.org/issues/16344
+        * 2: https://www.illumos.org/issues/13726
+        */
+#ifdef __illumos__
+       DIAG_OFF_STRICT_PROTOTYPES
+#endif /* __illumos__ */
        if ((oldhandler = setsignal(SIGHUP, cleanup)) != SIG_DFL)
+#ifdef __illumos__
+       DIAG_ON_STRICT_PROTOTYPES
+#endif /* __illumos__ */
                (void)setsignal(SIGHUP, oldhandler);
 #endif /* _WIN32 */
 
@@ -2737,7 +2751,14 @@ static void
                )
                new.sa_flags = SA_RESTART;
        if (sigaction(sig, &new, &old) < 0)
+               /* The same workaround as for SIG_DFL above. */
+#ifdef __illumos__
+               DIAG_OFF_STRICT_PROTOTYPES
+#endif /* __illumos__ */
                return (SIG_ERR);
+#ifdef __illumos__
+               DIAG_ON_STRICT_PROTOTYPES
+#endif /* __illumos__ */
        return (old.sa_handler);
 #endif
 }