diff mbox series

[nft,v2,4/5] rule: Refactor chain_print_declaration()

Message ID 20170928151745.28426-5-phil@nwl.cc
State Accepted
Delegated to: Pablo Neira
Headers show
Series Get output under application control | expand

Commit Message

Phil Sutter Sept. 28, 2017, 3:17 p.m. UTC
Instead of having two nearly identical printf() calls for netdev and
other chains, print the common parts separately and include the device
bit only for netdev chains.

Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 src/rule.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

Comments

Pablo Neira Ayuso Sept. 29, 2017, 10:26 a.m. UTC | #1
On Thu, Sep 28, 2017 at 05:17:44PM +0200, Phil Sutter wrote:
> Instead of having two nearly identical printf() calls for netdev and
> other chains, print the common parts separately and include the device
> bit only for netdev chains.

Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox series

Patch

diff --git a/src/rule.c b/src/rule.c
index 85505aecd5091..91129734a3d8f 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -666,18 +666,12 @@  static void chain_print_declaration(const struct chain *chain)
 {
 	printf("\tchain %s {\n", chain->handle.chain);
 	if (chain->flags & CHAIN_F_BASECHAIN) {
-		if (chain->dev != NULL) {
-			printf("\t\ttype %s hook %s device %s priority %d; policy %s;\n",
-			       chain->type,
-			       hooknum2str(chain->handle.family, chain->hooknum),
-			       chain->dev, chain->priority,
-			       chain_policy2str(chain->policy));
-		} else {
-			printf("\t\ttype %s hook %s priority %d; policy %s;\n",
-			       chain->type,
-			       hooknum2str(chain->handle.family, chain->hooknum),
-			       chain->priority, chain_policy2str(chain->policy));
-		}
+		printf("\t\ttype %s hook %s", chain->type,
+		       hooknum2str(chain->handle.family, chain->hooknum));
+		if (chain->dev != NULL)
+			printf(" device %s", chain->dev);
+		printf(" priority %d; policy %s;\n",
+		       chain->priority, chain_policy2str(chain->policy));
 	}
 }