diff options
author | Phil Sutter <phil@nwl.cc> | 2021-11-27 00:18:28 +0100 |
---|---|---|
committer | Phil Sutter <phil@nwl.cc> | 2021-12-16 14:30:29 +0100 |
commit | 51e5d29357644965bc6a8a4d1f3b2878936147f7 (patch) | |
tree | e2ce6355b527d1de1629dbacd83d4923e1c03c48 /iptables/ip6tables.c | |
parent | 56ac0452a4968f1af8d3ad1717c8646593177155 (diff) |
xshared: Share exit_tryhelp()
The function existed three times in identical form. Avoid having to
declare extern int line in xshared.c by making it a parameter.
Signed-off-by: Phil Sutter <phil@nwl.cc>
Diffstat (limited to 'iptables/ip6tables.c')
-rw-r--r-- | iptables/ip6tables.c | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/iptables/ip6tables.c b/iptables/ip6tables.c index 46f7785b..788966d6 100644 --- a/iptables/ip6tables.c +++ b/iptables/ip6tables.c @@ -100,17 +100,6 @@ struct xtables_globals ip6tables_globals = { #define prog_name ip6tables_globals.program_name #define prog_vers ip6tables_globals.program_version -static void __attribute__((noreturn)) -exit_tryhelp(int status) -{ - if (line != -1) - fprintf(stderr, "Error occurred at line: %d\n", line); - fprintf(stderr, "Try `%s -h' or '%s --help' for more information.\n", - prog_name, prog_name); - xtables_free_opts(1); - exit(status); -} - static void exit_printhelp(const struct xtables_rule_match *matches) { @@ -129,7 +118,7 @@ ip6tables_exit_error(enum xtables_exittype status, const char *msg, ...) va_end(args); fprintf(stderr, "\n"); if (status == PARAMETER_PROBLEM) - exit_tryhelp(status); + exit_tryhelp(status, line); if (status == VERSION_PROBLEM) fprintf(stderr, "Perhaps ip6tables or your kernel needs to be upgraded.\n"); @@ -1106,7 +1095,7 @@ int do_command6(int argc, char *argv[], char **table, if (line != -1) return 1; /* success: line ignored */ fprintf(stderr, "This is the IPv6 version of ip6tables.\n"); - exit_tryhelp(2); + exit_tryhelp(2, line); case '6': /* This is indeed the IPv6 ip6tables */ @@ -1123,7 +1112,7 @@ int do_command6(int argc, char *argv[], char **table, continue; } fprintf(stderr, "Bad argument `%s'\n", optarg); - exit_tryhelp(2); + exit_tryhelp(2, line); default: if (command_default(&cs, &ip6tables_globals, invert)) @@ -1372,7 +1361,7 @@ int do_command6(int argc, char *argv[], char **table, break; default: /* We should never reach this... */ - exit_tryhelp(2); + exit_tryhelp(2, line); } if (verbose > 1) |