From c0711693ab166b22664a68f01224c4ba682e1207 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Sun, 14 Feb 2021 12:54:42 -0800 Subject: [PATCH] Enable -Wredundant-decls. Add it to the default list of checks, and fix some errors it causes. (Sadly, it doesn't work in CLang.) --- CMakeLists.txt | 7 +------ capinfos.c | 15 ++++++++++----- captype.c | 15 ++++++++++----- dumpcap.c | 15 ++++++++++----- editcap.c | 15 ++++++++++----- extcap/extcap-base.c | 16 +++++++++++----- extcap/extcap-base.h | 15 ++++++++++----- mergecap.c | 15 ++++++++++----- plugins/epan/profinet/packet-pn-rsi.c | 3 --- randpkt.c | 16 +++++++++++----- rawshark.c | 17 +++++++++++------ reordercap.c | 15 ++++++++++----- text2pcap.c | 15 ++++++++++----- tfshark.c | 15 ++++++++++----- tools/lemon/lemon.c | 3 +-- tshark.c | 15 ++++++++++----- ui/commandline.c | 15 ++++++++++----- ui/qt/main.cpp | 15 ++++++++++----- 18 files changed, 155 insertions(+), 87 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f6e807af9ec..26ff0aa36d6 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 05110e3880f..ddc224d2e95 100644 --- a/capinfos.c +++ b/capinfos.c @@ -51,8 +51,17 @@ #include #include -#ifdef HAVE_GETOPT_H +/* + * If we have getopt_long() in the system library, include . + * 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 +#else +#include #endif #include @@ -76,10 +85,6 @@ #include -#ifndef HAVE_GETOPT_LONG -#include "wsutil/wsgetopt.h" -#endif - #include "ui/failure_message.h" #define INVALID_OPTION 1 diff --git a/captype.c b/captype.c index e3ee9c929f8..0a620af0c48 100644 --- a/captype.c +++ b/captype.c @@ -20,8 +20,17 @@ #include #include -#ifdef HAVE_GETOPT_H +/* + * If we have getopt_long() in the system library, include . + * 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 +#else +#include #endif #include @@ -42,10 +51,6 @@ #include #include -#ifndef HAVE_GETOPT_LONG -#include "wsutil/wsgetopt.h" -#endif - #include "ui/failure_message.h" static void diff --git a/dumpcap.c b/dumpcap.c index 24c8a610abd..8a64a205101 100644 --- a/dumpcap.c +++ b/dumpcap.c @@ -21,8 +21,17 @@ #include #endif -#ifdef HAVE_GETOPT_H +/* + * If we have getopt_long() in the system library, include . + * 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 +#else +#include #endif #if defined(__APPLE__) && defined(__LP64__) @@ -39,10 +48,6 @@ #include -#ifndef HAVE_GETOPT_LONG -#include "wsutil/wsgetopt.h" -#endif - #ifdef HAVE_LIBCAP # include # include diff --git a/editcap.c b/editcap.c index 3751aad84a3..cc90d33a2aa 100644 --- a/editcap.c +++ b/editcap.c @@ -40,8 +40,17 @@ #include #endif -#ifdef HAVE_GETOPT_H +/* + * If we have getopt_long() in the system library, include . + * 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 +#else +#include #endif #include @@ -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 /* getpid */ #include diff --git a/extcap/extcap-base.c b/extcap/extcap-base.c index 68c15ae57db..bc09aa6c545 100644 --- a/extcap/extcap-base.c +++ b/extcap/extcap-base.c @@ -19,13 +19,19 @@ #include #include -#ifdef HAVE_GETOPT_H - #include +/* + * If we have getopt_long() in the system library, include . + * 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 +#else +#include #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 11c4431093a..20d4be31c3d 100644 --- a/extcap/extcap-base.h +++ b/extcap/extcap-base.h @@ -19,12 +19,17 @@ #include #include -#ifdef HAVE_GETOPT_H +/* + * If we have getopt_long() in the system library, include . + * 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 -#endif - -#ifndef HAVE_GETOPT_LONG - #include "wsutil/wsgetopt.h" +#else + #include #endif #ifdef _WIN32 diff --git a/mergecap.c b/mergecap.c index f9a6c417ebf..96856b533fa 100644 --- a/mergecap.c +++ b/mergecap.c @@ -18,18 +18,23 @@ #include #include -#ifdef HAVE_GETOPT_H +/* + * If we have getopt_long() in the system library, include . + * 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 +#else +#include #endif #include #include -#ifndef HAVE_GETOPT_LONG -#include -#endif - #include #include #include diff --git a/plugins/epan/profinet/packet-pn-rsi.c b/plugins/epan/profinet/packet-pn-rsi.c index 297278cc814..ef6e5fd0b5e 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) diff --git a/randpkt.c b/randpkt.c index d97ef04e397..e4c05fe14aa 100644 --- a/randpkt.c +++ b/randpkt.c @@ -27,12 +27,18 @@ #endif #include -#ifdef HAVE_GETOPT_H -#include -#endif -#ifndef HAVE_GETOPT_LONG -#include "wsutil/wsgetopt.h" +/* + * If we have getopt_long() in the system library, include . + * 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 +#else +#include #endif #include "randpkt_core/randpkt_core.h" diff --git a/rawshark.c b/rawshark.c index 4f6585603d5..aa822ab07f2 100644 --- a/rawshark.c +++ b/rawshark.c @@ -33,14 +33,19 @@ #include #endif -#ifdef HAVE_GETOPT_H -#include -#endif - #include -#ifndef HAVE_GETOPT_LONG -#include "wsutil/wsgetopt.h" +/* + * If we have getopt_long() in the system library, include . + * 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 +#else +#include #endif #include diff --git a/reordercap.c b/reordercap.c index 3d225bdec0a..17408a848ba 100644 --- a/reordercap.c +++ b/reordercap.c @@ -15,16 +15,21 @@ #include #include -#ifdef HAVE_GETOPT_H +/* + * If we have getopt_long() in the system library, include . + * 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 +#else +#include #endif #include -#ifndef HAVE_GETOPT_LONG -#include "wsutil/wsgetopt.h" -#endif - #include #include #include diff --git a/text2pcap.c b/text2pcap.c index 8e3a1b7273f..9cdee935dea 100644 --- a/text2pcap.c +++ b/text2pcap.c @@ -112,17 +112,22 @@ #include #include -#ifdef HAVE_GETOPT_H +/* + * If we have getopt_long() in the system library, include . + * 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 +#else +#include #endif #include #include -#ifndef HAVE_GETOPT_LONG -#include "wsutil/wsgetopt.h" -#endif - #ifndef HAVE_STRPTIME # include "wsutil/strptime.h" #endif diff --git a/tfshark.c b/tfshark.c index b3b3f22fa0e..89961f093f3 100644 --- a/tfshark.c +++ b/tfshark.c @@ -17,16 +17,21 @@ #include #include -#ifdef HAVE_GETOPT_H +/* + * If we have getopt_long() in the system library, include . + * 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 +#else +#include #endif #include -#ifndef HAVE_GETOPT_LONG -#include "wsutil/wsgetopt.h" -#endif - #include #include diff --git a/tools/lemon/lemon.c b/tools/lemon/lemon.c index 387d094b7fa..8f990824a99 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(); \ } diff --git a/tshark.c b/tshark.c index e1247c1537a..0239c04f9bd 100644 --- a/tshark.c +++ b/tshark.c @@ -18,8 +18,17 @@ #include #include -#ifdef HAVE_GETOPT_H +/* + * If we have getopt_long() in the system library, include . + * 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 +#else +#include #endif #include @@ -32,10 +41,6 @@ #include #endif -#ifndef HAVE_GETOPT_LONG -#include "wsutil/wsgetopt.h" -#endif - #include #include diff --git a/ui/commandline.c b/ui/commandline.c index e14daa58b91..3dd4c5dd87b 100644 --- a/ui/commandline.c +++ b/ui/commandline.c @@ -16,12 +16,17 @@ #include #include -#ifdef HAVE_GETOPT_H +/* + * If we have getopt_long() in the system library, include . + * 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 -#endif - -#ifndef HAVE_GETOPT_LONG -#include "wsutil/wsgetopt.h" +#else +#include #endif #include diff --git a/ui/qt/main.cpp b/ui/qt/main.cpp index 6032054e55b..705681e10bd 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 . + * 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 -#endif - -#ifndef HAVE_GETOPT_LONG -#include "wsutil/wsgetopt.h" +#else +#include #endif #include