diff mbox series

[iptables] ebtables: Use xtables_exit_err()

Message ID 20181123143253.27332-1-phil@nwl.cc
State Accepted
Headers show
Series [iptables] ebtables: Use xtables_exit_err() | expand

Commit Message

Phil Sutter Nov. 23, 2018, 2:32 p.m. UTC
When e.g. ebtables-nft detects an incompatible table, a stray '.' was
printed as last line of output:

| # ebtables-nft -L
| table `filter' is incompatible, use 'nft' tool.
| .

This comes from ebtables' own exit_err callback. Instead use the common
one which also provides useful version information.

While being at it, align the final error message in xtables_eb_main()
with how the others print it.

Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 iptables/xtables-eb-standalone.c |  2 +-
 iptables/xtables-eb.c            | 15 ++-------------
 2 files changed, 3 insertions(+), 14 deletions(-)

Comments

Florian Westphal Nov. 23, 2018, 2:58 p.m. UTC | #1
Phil Sutter <phil@nwl.cc> wrote:
> When e.g. ebtables-nft detects an incompatible table, a stray '.' was
> printed as last line of output:
> 
> | # ebtables-nft -L
> | table `filter' is incompatible, use 'nft' tool.
> | .
> 
> This comes from ebtables' own exit_err callback. Instead use the common
> one which also provides useful version information.

Applied, thanks.
diff mbox series

Patch

diff --git a/iptables/xtables-eb-standalone.c b/iptables/xtables-eb-standalone.c
index 84ce0b60a7076..fb3daba0bd604 100644
--- a/iptables/xtables-eb-standalone.c
+++ b/iptables/xtables-eb-standalone.c
@@ -54,7 +54,7 @@  int xtables_eb_main(int argc, char *argv[])
 		ret = nft_commit(&h);
 
 	if (!ret)
-		fprintf(stderr, "%s\n", nft_strerror(errno));
+		fprintf(stderr, "ebtables: %s\n", nft_strerror(errno));
 
 	exit(!ret);
 }
diff --git a/iptables/xtables-eb.c b/iptables/xtables-eb.c
index f1aba555186eb..efc1f16ac6364 100644
--- a/iptables/xtables-eb.c
+++ b/iptables/xtables-eb.c
@@ -291,23 +291,12 @@  struct option ebt_original_options[] =
 	{ 0 }
 };
 
-static void __attribute__((__noreturn__,format(printf,2,3)))
-ebt_print_error(enum xtables_exittype status, const char *format, ...)
-{
-	va_list l;
-
-	va_start(l, format);
-	vfprintf(stderr, format, l);
-	fprintf(stderr, ".\n");
-	va_end(l);
-	exit(-1);
-}
-
+extern void xtables_exit_error(enum xtables_exittype status, const char *msg, ...) __attribute__((noreturn, format(printf,2,3)));
 struct xtables_globals ebtables_globals = {
 	.option_offset 		= 0,
 	.program_version	= IPTABLES_VERSION,
 	.orig_opts		= ebt_original_options,
-	.exit_err		= ebt_print_error,
+	.exit_err		= xtables_exit_error,
 	.compat_rev		= nft_compatible_revision,
 };