From 0b63936140032deac44072951451bdf47b54296a Mon Sep 17 00:00:00 2001 From: Patrick McHardy Date: Sat, 8 Sep 2007 16:00:01 +0000 Subject: Fix more sparse warnings: non-C99 array declaration, incorrect function prototypes --- include/xtables.h | 2 - ip6tables.c | 44 +++++++++++----------- iptables.c | 108 +++++++++++++++++++++++++++--------------------------- libiptc/libiptc.c | 16 ++++---- 4 files changed, 84 insertions(+), 86 deletions(-) diff --git a/include/xtables.h b/include/xtables.h index 5f0caea3..de5ecb13 100644 --- a/include/xtables.h +++ b/include/xtables.h @@ -220,8 +220,6 @@ enum exittype { /* this is a special 64bit data type that is 8-byte aligned */ #define aligned_u64 u_int64_t __attribute__((aligned(8))) -extern void exit_printhelp() __attribute__((noreturn)); -extern void exit_tryhelp(int) __attribute__((noreturn)); int check_inverse(const char option[], int *invert, int *optind, int argc); void exit_error(enum exittype, const char *, ...)__attribute__((noreturn, format(printf,2,3))); diff --git a/ip6tables.c b/ip6tables.c index d43029eb..3a54c86f 100644 --- a/ip6tables.c +++ b/ip6tables.c @@ -267,27 +267,7 @@ static void free_opts(int reset_offset) } } -void -exit_error(enum exittype status, const char *msg, ...) -{ - va_list args; - - va_start(args, msg); - fprintf(stderr, "%s v%s: ", program_name, program_version); - vfprintf(stderr, msg, args); - va_end(args); - fprintf(stderr, "\n"); - if (status == PARAMETER_PROBLEM) - exit_tryhelp(status); - if (status == VERSION_PROBLEM) - fprintf(stderr, - "Perhaps ip6tables or your kernel needs to be upgraded.\n"); - /* On error paths, make sure that we don't leak memory */ - free_opts(1); - exit(status); -} - -void +static void exit_tryhelp(int status) { if (line != -1) @@ -298,7 +278,7 @@ exit_tryhelp(int status) exit(status); } -void +static void exit_printhelp(struct ip6tables_rule_match *matches) { struct ip6tables_rule_match *matchp = NULL; @@ -380,6 +360,26 @@ exit_printhelp(struct ip6tables_rule_match *matches) exit(0); } +void +exit_error(enum exittype status, const char *msg, ...) +{ + va_list args; + + va_start(args, msg); + fprintf(stderr, "%s v%s: ", program_name, program_version); + vfprintf(stderr, msg, args); + va_end(args); + fprintf(stderr, "\n"); + if (status == PARAMETER_PROBLEM) + exit_tryhelp(status); + if (status == VERSION_PROBLEM) + fprintf(stderr, + "Perhaps ip6tables or your kernel needs to be upgraded.\n"); + /* On error paths, make sure that we don't leak memory */ + free_opts(1); + exit(status); +} + static void generic_opt_check(int command, int options) { diff --git a/iptables.c b/iptables.c index 549c6cd0..900e8fc1 100644 --- a/iptables.c +++ b/iptables.c @@ -99,38 +99,38 @@ static const char optflags[NUMBER_OF_OPT] = { 'n', 's', 'd', 'p', 'j', 'v', 'x', 'i', 'o', 'f', '0', 'c'}; static struct option original_opts[] = { - { "append", 1, 0, 'A' }, - { "delete", 1, 0, 'D' }, - { "insert", 1, 0, 'I' }, - { "replace", 1, 0, 'R' }, - { "list", 2, 0, 'L' }, - { "flush", 2, 0, 'F' }, - { "zero", 2, 0, 'Z' }, - { "new-chain", 1, 0, 'N' }, - { "delete-chain", 2, 0, 'X' }, - { "rename-chain", 1, 0, 'E' }, - { "policy", 1, 0, 'P' }, - { "source", 1, 0, 's' }, - { "destination", 1, 0, 'd' }, - { "src", 1, 0, 's' }, /* synonym */ - { "dst", 1, 0, 'd' }, /* synonym */ - { "protocol", 1, 0, 'p' }, - { "in-interface", 1, 0, 'i' }, - { "jump", 1, 0, 'j' }, - { "table", 1, 0, 't' }, - { "match", 1, 0, 'm' }, - { "numeric", 0, 0, 'n' }, - { "out-interface", 1, 0, 'o' }, - { "verbose", 0, 0, 'v' }, - { "exact", 0, 0, 'x' }, - { "fragments", 0, 0, 'f' }, - { "version", 0, 0, 'V' }, - { "help", 2, 0, 'h' }, - { "line-numbers", 0, 0, '0' }, - { "modprobe", 1, 0, 'M' }, - { "set-counters", 1, 0, 'c' }, - { "goto", 1, 0, 'g' }, - { 0 } + { "append", 1, NULL, 'A' }, + { "delete", 1, NULL, 'D' }, + { "insert", 1, NULL, 'I' }, + { "replace", 1, NULL, 'R' }, + { "list", 2, NULL, 'L' }, + { "flush", 2, NULL, 'F' }, + { "zero", 2, NULL, 'Z' }, + { "new-chain", 1, NULL, 'N' }, + { "delete-chain", 2, NULL, 'X' }, + { "rename-chain", 1, NULL, 'E' }, + { "policy", 1, NULL, 'P' }, + { "source", 1, NULL, 's' }, + { "destination", 1, NULL, 'd' }, + { "src", 1, NULL, 's' }, /* synonym */ + { "dst", 1, NULL, 'd' }, /* synonym */ + { "protocol", 1, NULL, 'p' }, + { "in-interface", 1, NULL, 'i' }, + { "jump", 1, NULL, 'j' }, + { "table", 1, NULL, 't' }, + { "match", 1, NULL, 'm' }, + { "numeric", 0, NULL, 'n' }, + { "out-interface", 1, NULL, 'o' }, + { "verbose", 0, NULL, 'v' }, + { "exact", 0, NULL, 'x' }, + { "fragments", 0, NULL, 'f' }, + { "version", 0, NULL, 'V' }, + { "help", 2, NULL, 'h' }, + { "line-numbers", 0, NULL, '0' }, + { "modprobe", 1, NULL, 'M' }, + { "set-counters", 1, NULL, 'c' }, + { "goto", 1, NULL, 'g' }, + { } }; /* we need this for iptables-restore. iptables-restore.c sets line to the @@ -347,27 +347,7 @@ static void free_opts(int reset_offset) } } -void -exit_error(enum exittype status, const char *msg, ...) -{ - va_list args; - - va_start(args, msg); - fprintf(stderr, "%s v%s: ", program_name, program_version); - vfprintf(stderr, msg, args); - va_end(args); - fprintf(stderr, "\n"); - if (status == PARAMETER_PROBLEM) - exit_tryhelp(status); - if (status == VERSION_PROBLEM) - fprintf(stderr, - "Perhaps iptables or your kernel needs to be upgraded.\n"); - /* On error paths, make sure that we don't leak memory */ - free_opts(1); - exit(status); -} - -void +static void exit_tryhelp(int status) { if (line != -1) @@ -378,7 +358,7 @@ exit_tryhelp(int status) exit(status); } -void +static void exit_printhelp(struct iptables_rule_match *matches) { struct iptables_rule_match *matchp = NULL; @@ -464,6 +444,26 @@ exit_printhelp(struct iptables_rule_match *matches) exit(0); } +void +exit_error(enum exittype status, const char *msg, ...) +{ + va_list args; + + va_start(args, msg); + fprintf(stderr, "%s v%s: ", program_name, program_version); + vfprintf(stderr, msg, args); + va_end(args); + fprintf(stderr, "\n"); + if (status == PARAMETER_PROBLEM) + exit_tryhelp(status); + if (status == VERSION_PROBLEM) + fprintf(stderr, + "Perhaps iptables or your kernel needs to be upgraded.\n"); + /* On error paths, make sure that we don't leak memory */ + free_opts(1); + exit(status); +} + static void generic_opt_check(int command, int options) { diff --git a/libiptc/libiptc.c b/libiptc/libiptc.c index 574cc0ab..9e4571ce 100644 --- a/libiptc/libiptc.c +++ b/libiptc/libiptc.c @@ -48,14 +48,14 @@ static int sockfd = -1; static int sockfd_use = 0; static void *iptc_fn = NULL; -static const char *hooknames[] -= { [HOOK_PRE_ROUTING] "PREROUTING", - [HOOK_LOCAL_IN] "INPUT", - [HOOK_FORWARD] "FORWARD", - [HOOK_LOCAL_OUT] "OUTPUT", - [HOOK_POST_ROUTING] "POSTROUTING", +static const char *hooknames[] = { + [HOOK_PRE_ROUTING] = "PREROUTING", + [HOOK_LOCAL_IN] = "INPUT", + [HOOK_FORWARD] = "FORWARD", + [HOOK_LOCAL_OUT] = "OUTPUT", + [HOOK_POST_ROUTING] = "POSTROUTING", #ifdef HOOK_DROPPING - [HOOK_DROPPING] "DROPPING" + [HOOK_DROPPING] = "DROPPING" #endif }; @@ -2206,7 +2206,7 @@ out_zero: /* Get raw socket. */ int -TC_GET_RAW_SOCKET() +TC_GET_RAW_SOCKET(void) { return sockfd; } -- cgit v1.2.3