Skip to content

Commit

Permalink
Enable -Wredundant-decls.
Browse files Browse the repository at this point in the history
Add it to the default list of checks, and fix some errors it causes.
(Sadly, it doesn't work in CLang.)
  • Loading branch information
guyharris committed Feb 14, 2021
1 parent 3387eef commit c071169
Show file tree
Hide file tree
Showing 18 changed files with 155 additions and 87 deletions.
7 changes: 1 addition & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,7 @@ else() # ! MSVC
-Wheader-guard
-Wcomma
-Wshorten-64-to-32
-Wredundant-decls
)

#
Expand Down Expand Up @@ -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
Expand Down
15 changes: 10 additions & 5 deletions capinfos.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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
Expand Down
15 changes: 10 additions & 5 deletions captype.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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
Expand Down
15 changes: 10 additions & 5 deletions dumpcap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand All @@ -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>
Expand Down
15 changes: 10 additions & 5 deletions editcap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>
Expand Down
16 changes: 11 additions & 5 deletions extcap/extcap-base.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
15 changes: 10 additions & 5 deletions extcap/extcap-base.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 10 additions & 5 deletions mergecap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
3 changes: 0 additions & 3 deletions plugins/epan/profinet/packet-pn-rsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 11 additions & 5 deletions randpkt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
17 changes: 11 additions & 6 deletions rawshark.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
15 changes: 10 additions & 5 deletions reordercap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
15 changes: 10 additions & 5 deletions text2pcap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 10 additions & 5 deletions tfshark.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
3 changes: 1 addition & 2 deletions tools/lemon/lemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -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*));

Expand Down Expand Up @@ -430,7 +430,6 @@ struct lemon {
};

#define MemoryCheck(X) if((X)==0){ \
extern void memory_error(); \
memory_error(); \
}

Expand Down
Loading

0 comments on commit c071169

Please sign in to comment.