All of lore.kernel.org
 help / color / mirror / Atom feed
* [iptables PATCH v2 1/2] nft: Fix command name in ip6tables error message
@ 2020-08-07 12:02 Phil Sutter
  2020-08-07 12:02 ` [iptables PATCH v2 2/2] tests: shell: Merge and extend return codes test Phil Sutter
  2020-08-13  2:02 ` [iptables PATCH v2 1/2] nft: Fix command name in ip6tables error message Pablo Neira Ayuso
  0 siblings, 2 replies; 4+ messages in thread
From: Phil Sutter @ 2020-08-07 12:02 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: netfilter-devel

Upon errors, ip6tables-nft would prefix its error messages with
'iptables:' instead of 'ip6tables:'. Turns out the command name was
hard-coded, use 'progname' variable instead.
While being at it, merge the two mostly identical fprintf() calls into
one.

Signed-off-by: Phil Sutter <phil@nwl.cc>
---
Changes since v1:
- Added this fix. Related test ignored the prefix value, so this went
  unnoticed.
---
 iptables/xtables-standalone.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/iptables/xtables-standalone.c b/iptables/xtables-standalone.c
index dd6fb7919d2e1..7b71db62f1ea6 100644
--- a/iptables/xtables-standalone.c
+++ b/iptables/xtables-standalone.c
@@ -75,14 +75,10 @@ xtables_main(int family, const char *progname, int argc, char *argv[])
 	xtables_fini();
 
 	if (!ret) {
-		if (errno == EINVAL) {
-			fprintf(stderr, "iptables: %s. "
-					"Run `dmesg' for more information.\n",
-				nft_strerror(errno));
-		} else {
-			fprintf(stderr, "iptables: %s.\n",
-				nft_strerror(errno));
-		}
+		fprintf(stderr, "%s: %s.%s\n", progname, nft_strerror(errno),
+			(errno == EINVAL ?
+			 " Run `dmesg' for more information." : ""));
+
 		if (errno == EAGAIN)
 			exit(RESOURCE_PROBLEM);
 	}
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-08-13  2:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-07 12:02 [iptables PATCH v2 1/2] nft: Fix command name in ip6tables error message Phil Sutter
2020-08-07 12:02 ` [iptables PATCH v2 2/2] tests: shell: Merge and extend return codes test Phil Sutter
2020-08-13  2:03   ` Pablo Neira Ayuso
2020-08-13  2:02 ` [iptables PATCH v2 1/2] nft: Fix command name in ip6tables error message Pablo Neira Ayuso

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.