diff options
author | Guy Harris <gharris@sonic.net> | 2021-02-14 12:54:42 -0800 |
---|---|---|
committer | Guy Harris <gharris@sonic.net> | 2021-02-14 14:43:42 -0800 |
commit | c0711693ab166b22664a68f01224c4ba682e1207 (patch) | |
tree | 136ac536c7ec89f94b337ef9c3ef3f13469e6f03 | |
parent | 3387eef8367ca7b16b5515635f79d971bde97c5e (diff) |
Enable -Wredundant-decls.
Add it to the default list of checks, and fix some errors it causes.
(Sadly, it doesn't work in CLang.)
-rw-r--r-- | CMakeLists.txt | 7 | ||||
-rw-r--r-- | capinfos.c | 15 | ||||
-rw-r--r-- | captype.c | 15 | ||||
-rw-r--r-- | dumpcap.c | 15 | ||||
-rw-r--r-- | editcap.c | 15 | ||||
-rw-r--r-- | extcap/extcap-base.c | 16 | ||||
-rw-r--r-- | extcap/extcap-base.h | 15 | ||||
-rw-r--r-- | mergecap.c | 15 | ||||
-rw-r--r-- | plugins/epan/profinet/packet-pn-rsi.c | 3 | ||||
-rw-r--r-- | randpkt.c | 16 | ||||
-rw-r--r-- | rawshark.c | 17 | ||||
-rw-r--r-- | reordercap.c | 15 | ||||
-rw-r--r-- | text2pcap.c | 15 | ||||
-rw-r--r-- | tfshark.c | 15 | ||||
-rw-r--r-- | tools/lemon/lemon.c | 3 | ||||
-rw-r--r-- | tshark.c | 15 | ||||
-rw-r--r-- | ui/commandline.c | 15 | ||||
-rw-r--r-- | ui/qt/main.cpp | 15 |
18 files changed, 155 insertions, 87 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index f6e807af9e..26ff0aa36d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -582,6 +582,7 @@ else() # ! MSVC -Wheader-guard -Wcomma -Wshorten-64-to-32 + -Wredundant-decls ) # @@ -675,12 +676,6 @@ else() # ! MSVC # -Wcast-qual # - # Some generated ASN.1 dissectors block this one; - # multiple function declarations for the same - # function are being generated. - # - -Wredundant-decls - # # All the registration functions block these for now. # -Wmissing-prototypes diff --git a/capinfos.c b/capinfos.c index 05110e3880..ddc224d2e9 100644 --- a/capinfos.c +++ b/capinfos.c @@ -51,8 +51,17 @@ #include <locale.h> #include <errno.h> -#ifdef HAVE_GETOPT_H +/* + * If we have getopt_long() in the system library, include <getopt.h>. + * Otherwise, we're using our own getopt_long() (either because the + * system has getopt() but not getopt_long(), as with some UN*Xes, + * or because it doesn't even have getopt(), as with Windows), so + * include our getopt_long()'s header. + */ +#ifdef HAVE_GETOPT_LONG #include <getopt.h> +#else +#include <wsutil/wsgetopt.h> #endif #include <glib.h> @@ -76,10 +85,6 @@ #include <wsutil/wsgcrypt.h> -#ifndef HAVE_GETOPT_LONG -#include "wsutil/wsgetopt.h" -#endif - #include "ui/failure_message.h" #define INVALID_OPTION 1 @@ -20,8 +20,17 @@ #include <locale.h> #include <errno.h> -#ifdef HAVE_GETOPT_H +/* + * If we have getopt_long() in the system library, include <getopt.h>. + * Otherwise, we're using our own getopt_long() (either because the + * system has getopt() but not getopt_long(), as with some UN*Xes, + * or because it doesn't even have getopt(), as with Windows), so + * include our getopt_long()'s header. + */ +#ifdef HAVE_GETOPT_LONG #include <getopt.h> +#else +#include <wsutil/wsgetopt.h> #endif #include <glib.h> @@ -42,10 +51,6 @@ #include <wsutil/report_message.h> #include <wsutil/str_util.h> -#ifndef HAVE_GETOPT_LONG -#include "wsutil/wsgetopt.h" -#endif - #include "ui/failure_message.h" static void @@ -21,8 +21,17 @@ #include <netinet/in.h> #endif -#ifdef HAVE_GETOPT_H +/* + * If we have getopt_long() in the system library, include <getopt.h>. + * Otherwise, we're using our own getopt_long() (either because the + * system has getopt() but not getopt_long(), as with some UN*Xes, + * or because it doesn't even have getopt(), as with Windows), so + * include our getopt_long()'s header. + */ +#ifdef HAVE_GETOPT_LONG #include <getopt.h> +#else +#include <wsutil/wsgetopt.h> #endif #if defined(__APPLE__) && defined(__LP64__) @@ -39,10 +48,6 @@ #include <wsutil/socket.h> -#ifndef HAVE_GETOPT_LONG -#include "wsutil/wsgetopt.h" -#endif - #ifdef HAVE_LIBCAP # include <sys/prctl.h> # include <sys/capability.h> @@ -40,8 +40,17 @@ #include <unistd.h> #endif -#ifdef HAVE_GETOPT_H +/* + * If we have getopt_long() in the system library, include <getopt.h>. + * Otherwise, we're using our own getopt_long() (either because the + * system has getopt() but not getopt_long(), as with some UN*Xes, + * or because it doesn't even have getopt(), as with Windows), so + * include our getopt_long()'s header. + */ +#ifdef HAVE_GETOPT_LONG #include <getopt.h> +#else +#include <wsutil/wsgetopt.h> #endif #include <wiretap/secrets-types.h> @@ -50,10 +59,6 @@ #include "epan/etypes.h" #include "epan/dissectors/packet-ieee80211-radiotap-defs.h" -#ifndef HAVE_GETOPT_LONG -#include "wsutil/wsgetopt.h" -#endif - #ifdef _WIN32 #include <process.h> /* getpid */ #include <winsock2.h> diff --git a/extcap/extcap-base.c b/extcap/extcap-base.c index 68c15ae57d..bc09aa6c54 100644 --- a/extcap/extcap-base.c +++ b/extcap/extcap-base.c @@ -19,13 +19,19 @@ #include <string.h> #include <errno.h> -#ifdef HAVE_GETOPT_H - #include <getopt.h> +/* + * If we have getopt_long() in the system library, include <getopt.h>. + * Otherwise, we're using our own getopt_long() (either because the + * system has getopt() but not getopt_long(), as with some UN*Xes, + * or because it doesn't even have getopt(), as with Windows), so + * include our getopt_long()'s header. + */ +#ifdef HAVE_GETOPT_LONG +#include <getopt.h> +#else +#include <wsutil/wsgetopt.h> #endif -#ifndef HAVE_GETOPT_LONG - #include "wsutil/wsgetopt.h" -#endif #include "ws_attributes.h" enum extcap_options { diff --git a/extcap/extcap-base.h b/extcap/extcap-base.h index 11c4431093..20d4be31c3 100644 --- a/extcap/extcap-base.h +++ b/extcap/extcap-base.h @@ -19,12 +19,17 @@ #include <stdlib.h> #include <stdint.h> -#ifdef HAVE_GETOPT_H +/* + * If we have getopt_long() in the system library, include <getopt.h>. + * Otherwise, we're using our own getopt_long() (either because the + * system has getopt() but not getopt_long(), as with some UN*Xes, + * or because it doesn't even have getopt(), as with Windows), so + * include our getopt_long()'s header. + */ +#ifdef HAVE_GETOPT_LONG #include <getopt.h> -#endif - -#ifndef HAVE_GETOPT_LONG - #include "wsutil/wsgetopt.h" +#else + #include <wsutil/wsgetopt.h> #endif #ifdef _WIN32 diff --git a/mergecap.c b/mergecap.c index f9a6c417eb..96856b533f 100644 --- a/mergecap.c +++ b/mergecap.c @@ -18,18 +18,23 @@ #include <errno.h> #include <glib.h> -#ifdef HAVE_GETOPT_H +/* + * If we have getopt_long() in the system library, include <getopt.h>. + * Otherwise, we're using our own getopt_long() (either because the + * system has getopt() but not getopt_long(), as with some UN*Xes, + * or because it doesn't even have getopt(), as with Windows), so + * include our getopt_long()'s header. + */ +#ifdef HAVE_GETOPT_LONG #include <getopt.h> +#else +#include <wsutil/wsgetopt.h> #endif #include <string.h> #include <wiretap/wtap.h> -#ifndef HAVE_GETOPT_LONG -#include <wsutil/wsgetopt.h> -#endif - #include <ui/clopts_common.h> #include <ui/cmdarg_err.h> #include <wsutil/filesystem.h> diff --git a/plugins/epan/profinet/packet-pn-rsi.c b/plugins/epan/profinet/packet-pn-rsi.c index 297278cc81..ef6e5fd0b5 100644 --- a/plugins/epan/profinet/packet-pn-rsi.c +++ b/plugins/epan/profinet/packet-pn-rsi.c @@ -229,9 +229,6 @@ static const range_string pn_rsi_interface[] = { { 0, NULL } };*/ -int dissect_blocks(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, guint8 *drep); - static int dissect_FOpnumOffset(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, guint8 *drep _U_, guint32 *u32FOpnumOffset) @@ -27,12 +27,18 @@ #endif #include <wsutil/report_message.h> -#ifdef HAVE_GETOPT_H -#include <getopt.h> -#endif -#ifndef HAVE_GETOPT_LONG -#include "wsutil/wsgetopt.h" +/* + * If we have getopt_long() in the system library, include <getopt.h>. + * Otherwise, we're using our own getopt_long() (either because the + * system has getopt() but not getopt_long(), as with some UN*Xes, + * or because it doesn't even have getopt(), as with Windows), so + * include our getopt_long()'s header. + */ +#ifdef HAVE_GETOPT_LONG +#include <getopt.h> +#else +#include <wsutil/wsgetopt.h> #endif #include "randpkt_core/randpkt_core.h" diff --git a/rawshark.c b/rawshark.c index 4f6585603d..aa822ab07f 100644 --- a/rawshark.c +++ b/rawshark.c @@ -33,14 +33,19 @@ #include <sys/resource.h> #endif -#ifdef HAVE_GETOPT_H -#include <getopt.h> -#endif - #include <errno.h> -#ifndef HAVE_GETOPT_LONG -#include "wsutil/wsgetopt.h" +/* + * If we have getopt_long() in the system library, include <getopt.h>. + * Otherwise, we're using our own getopt_long() (either because the + * system has getopt() but not getopt_long(), as with some UN*Xes, + * or because it doesn't even have getopt(), as with Windows), so + * include our getopt_long()'s header. + */ +#ifdef HAVE_GETOPT_LONG +#include <getopt.h> +#else +#include <wsutil/wsgetopt.h> #endif #include <glib.h> diff --git a/reordercap.c b/reordercap.c index 3d225bdec0..17408a848b 100644 --- a/reordercap.c +++ b/reordercap.c @@ -15,16 +15,21 @@ #include <string.h> #include <glib.h> -#ifdef HAVE_GETOPT_H +/* + * If we have getopt_long() in the system library, include <getopt.h>. + * Otherwise, we're using our own getopt_long() (either because the + * system has getopt() but not getopt_long(), as with some UN*Xes, + * or because it doesn't even have getopt(), as with Windows), so + * include our getopt_long()'s header. + */ +#ifdef HAVE_GETOPT_LONG #include <getopt.h> +#else +#include <wsutil/wsgetopt.h> #endif #include <wiretap/wtap.h> -#ifndef HAVE_GETOPT_LONG -#include "wsutil/wsgetopt.h" -#endif - #include <ui/cmdarg_err.h> #include <wsutil/filesystem.h> #include <wsutil/file_util.h> diff --git a/text2pcap.c b/text2pcap.c index 8e3a1b7273..9cdee935de 100644 --- a/text2pcap.c +++ b/text2pcap.c @@ -112,17 +112,22 @@ #include <time.h> #include <glib.h> -#ifdef HAVE_GETOPT_H +/* + * If we have getopt_long() in the system library, include <getopt.h>. + * Otherwise, we're using our own getopt_long() (either because the + * system has getopt() but not getopt_long(), as with some UN*Xes, + * or because it doesn't even have getopt(), as with Windows), so + * include our getopt_long()'s header. + */ +#ifdef HAVE_GETOPT_LONG #include <getopt.h> +#else +#include <wsutil/wsgetopt.h> #endif #include <errno.h> #include <assert.h> -#ifndef HAVE_GETOPT_LONG -#include "wsutil/wsgetopt.h" -#endif - #ifndef HAVE_STRPTIME # include "wsutil/strptime.h" #endif @@ -17,16 +17,21 @@ #include <locale.h> #include <limits.h> -#ifdef HAVE_GETOPT_H +/* + * If we have getopt_long() in the system library, include <getopt.h>. + * Otherwise, we're using our own getopt_long() (either because the + * system has getopt() but not getopt_long(), as with some UN*Xes, + * or because it doesn't even have getopt(), as with Windows), so + * include our getopt_long()'s header. + */ +#ifdef HAVE_GETOPT_LONG #include <getopt.h> +#else +#include <wsutil/wsgetopt.h> #endif #include <errno.h> -#ifndef HAVE_GETOPT_LONG -#include "wsutil/wsgetopt.h" -#endif - #include <glib.h> #include <epan/exceptions.h> diff --git a/tools/lemon/lemon.c b/tools/lemon/lemon.c index 387d094b7f..8f990824a9 100644 --- a/tools/lemon/lemon.c +++ b/tools/lemon/lemon.c @@ -48,7 +48,7 @@ extern int access(const char *path, int mode); #define MAXRHS 1000 #endif -extern void memory_error(); +extern void memory_error(void); static int showPrecedenceConflict = 0; static char *msort(char*,char**,int(*)(const char*,const char*)); @@ -430,7 +430,6 @@ struct lemon { }; #define MemoryCheck(X) if((X)==0){ \ - extern void memory_error(); \ memory_error(); \ } @@ -18,8 +18,17 @@ #include <locale.h> #include <limits.h> -#ifdef HAVE_GETOPT_H +/* + * If we have getopt_long() in the system library, include <getopt.h>. + * Otherwise, we're using our own getopt_long() (either because the + * system has getopt() but not getopt_long(), as with some UN*Xes, + * or because it doesn't even have getopt(), as with Windows), so + * include our getopt_long()'s header. + */ +#ifdef HAVE_GETOPT_LONG #include <getopt.h> +#else +#include <wsutil/wsgetopt.h> #endif #include <errno.h> @@ -32,10 +41,6 @@ #include <signal.h> #endif -#ifndef HAVE_GETOPT_LONG -#include "wsutil/wsgetopt.h" -#endif - #include <glib.h> #include <epan/exceptions.h> diff --git a/ui/commandline.c b/ui/commandline.c index e14daa58b9..3dd4c5dd87 100644 --- a/ui/commandline.c +++ b/ui/commandline.c @@ -16,12 +16,17 @@ #include <stdio.h> #include <stdlib.h> -#ifdef HAVE_GETOPT_H +/* + * If we have getopt_long() in the system library, include <getopt.h>. + * Otherwise, we're using our own getopt_long() (either because the + * system has getopt() but not getopt_long(), as with some UN*Xes, + * or because it doesn't even have getopt(), as with Windows), so + * include our getopt_long()'s header. + */ +#ifdef HAVE_GETOPT_LONG #include <getopt.h> -#endif - -#ifndef HAVE_GETOPT_LONG -#include "wsutil/wsgetopt.h" +#else +#include <wsutil/wsgetopt.h> #endif #include <version_info.h> diff --git a/ui/qt/main.cpp b/ui/qt/main.cpp index 6032054e55..705681e10b 100644 --- a/ui/qt/main.cpp +++ b/ui/qt/main.cpp @@ -21,12 +21,17 @@ #include "ui/win32/console_win32.h" #endif -#ifdef HAVE_GETOPT_H +/* + * If we have getopt_long() in the system library, include <getopt.h>. + * Otherwise, we're using our own getopt_long() (either because the + * system has getopt() but not getopt_long(), as with some UN*Xes, + * or because it doesn't even have getopt(), as with Windows), so + * include our getopt_long()'s header. + */ +#ifdef HAVE_GETOPT_LONG #include <getopt.h> -#endif - -#ifndef HAVE_GETOPT_LONG -#include "wsutil/wsgetopt.h" +#else +#include <wsutil/wsgetopt.h> #endif #include <ui/clopts_common.h> |