From 51e5d29357644965bc6a8a4d1f3b2878936147f7 Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Sat, 27 Nov 2021 00:18:28 +0100 Subject: 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 --- iptables/ip6tables.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) (limited to 'iptables/ip6tables.c') 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) -- cgit v1.2.3