Enable -Wredundant-decls.

Add it to the default list of checks, and fix some errors it causes.
(Sadly, it doesn't work in CLang.)
This commit is contained in:
Guy Harris 2021-02-14 12:54:42 -08:00
parent 3387eef836
commit c0711693ab
18 changed files with 155 additions and 87 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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>

View File

@ -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>

View File

@ -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 {

View File

@ -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

View File

@ -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>

View File

@ -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)

View File

@ -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"

View File

@ -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>

View File

@ -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>

View File

@ -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

View File

@ -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>

View File

@ -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(); \
}

View File

@ -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>

View File

@ -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>

View File

@ -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>