All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Machata <me@pmachata.org>
To: netdev@vger.kernel.org, dsahern@gmail.com, stephen@networkplumber.org
Cc: Petr Machata <me@pmachata.org>
Subject: [PATCH iproute2-next 5/7] ip: iplink_bridge_slave: Convert to use print_on_off()
Date: Sat, 14 Nov 2020 23:53:59 +0100	[thread overview]
Message-ID: <edde03541654d6dc1a19f2805b34cbea82a85a4f.1605393324.git.me@pmachata.org> (raw)
In-Reply-To: <cover.1605393324.git.me@pmachata.org>

Instead of rolling a custom on-off printer, use the one added to utils.c.
Note that _print_onoff() has an extra parameter for a JSON-specific flag
name. However that argument is not used, and never was. Therefore when
moving over to print_on_off(), drop this argument.

Signed-off-by: Petr Machata <me@pmachata.org>
---
 ip/iplink_bridge_slave.c | 34 +++++++++++++---------------------
 1 file changed, 13 insertions(+), 21 deletions(-)

diff --git a/ip/iplink_bridge_slave.c b/ip/iplink_bridge_slave.c
index f7f6da0c79b7..717875864b18 100644
--- a/ip/iplink_bridge_slave.c
+++ b/ip/iplink_bridge_slave.c
@@ -76,14 +76,6 @@ static void print_portstate(FILE *f, __u8 state)
 		print_int(PRINT_ANY, "state_index", "state (%d) ", state);
 }
 
-static void _print_onoff(FILE *f, char *json_flag, char *flag, __u8 val)
-{
-	if (is_json_context())
-		print_bool(PRINT_JSON, flag, NULL, val);
-	else
-		fprintf(f, "%s %s ", flag, val ? "on" : "off");
-}
-
 static void _print_timer(FILE *f, const char *attr, struct rtattr *timer)
 {
 	struct timeval tv;
@@ -145,27 +137,27 @@ static void bridge_slave_print_opt(struct link_util *lu, FILE *f,
 			  rta_getattr_u32(tb[IFLA_BRPORT_COST]));
 
 	if (tb[IFLA_BRPORT_MODE])
-		_print_onoff(f, "mode", "hairpin",
+		print_on_off(PRINT_ANY, "hairpin", "hairpin %s ",
 			     rta_getattr_u8(tb[IFLA_BRPORT_MODE]));
 
 	if (tb[IFLA_BRPORT_GUARD])
-		_print_onoff(f, "guard", "guard",
+		print_on_off(PRINT_ANY, "guard", "guard %s ",
 			     rta_getattr_u8(tb[IFLA_BRPORT_GUARD]));
 
 	if (tb[IFLA_BRPORT_PROTECT])
-		_print_onoff(f, "protect", "root_block",
+		print_on_off(PRINT_ANY, "root_block", "root_block %s ",
 			     rta_getattr_u8(tb[IFLA_BRPORT_PROTECT]));
 
 	if (tb[IFLA_BRPORT_FAST_LEAVE])
-		_print_onoff(f, "fast_leave", "fastleave",
+		print_on_off(PRINT_ANY, "fastleave", "fastleave %s ",
 			     rta_getattr_u8(tb[IFLA_BRPORT_FAST_LEAVE]));
 
 	if (tb[IFLA_BRPORT_LEARNING])
-		_print_onoff(f, "learning", "learning",
+		print_on_off(PRINT_ANY, "learning", "learning %s ",
 			     rta_getattr_u8(tb[IFLA_BRPORT_LEARNING]));
 
 	if (tb[IFLA_BRPORT_UNICAST_FLOOD])
-		_print_onoff(f, "unicast_flood", "flood",
+		print_on_off(PRINT_ANY, "flood", "flood %s ",
 			     rta_getattr_u8(tb[IFLA_BRPORT_UNICAST_FLOOD]));
 
 	if (tb[IFLA_BRPORT_ID])
@@ -233,11 +225,11 @@ static void bridge_slave_print_opt(struct link_util *lu, FILE *f,
 			   rta_getattr_u8(tb[IFLA_BRPORT_CONFIG_PENDING]));
 
 	if (tb[IFLA_BRPORT_PROXYARP])
-		_print_onoff(f, "proxyarp", "proxy_arp",
+		print_on_off(PRINT_ANY, "proxy_arp", "proxy_arp %s ",
 			     rta_getattr_u8(tb[IFLA_BRPORT_PROXYARP]));
 
 	if (tb[IFLA_BRPORT_PROXYARP_WIFI])
-		_print_onoff(f, "proxyarp_wifi", "proxy_arp_wifi",
+		print_on_off(PRINT_ANY, "proxy_arp_wifi", "proxy_arp_wifi %s ",
 			     rta_getattr_u8(tb[IFLA_BRPORT_PROXYARP_WIFI]));
 
 	if (tb[IFLA_BRPORT_MULTICAST_ROUTER])
@@ -255,15 +247,15 @@ static void bridge_slave_print_opt(struct link_util *lu, FILE *f,
 			     rta_getattr_u8(tb[IFLA_BRPORT_FAST_LEAVE]) ? "on" : "off");
 
 	if (tb[IFLA_BRPORT_MCAST_FLOOD])
-		_print_onoff(f, "mcast_flood", "mcast_flood",
+		print_on_off(PRINT_ANY, "mcast_flood", "mcast_flood %s ",
 			     rta_getattr_u8(tb[IFLA_BRPORT_MCAST_FLOOD]));
 
 	if (tb[IFLA_BRPORT_MCAST_TO_UCAST])
-		_print_onoff(f, "mcast_to_unicast", "mcast_to_unicast",
+		print_on_off(PRINT_ANY, "mcast_to_unicast", "mcast_to_unicast %s ",
 			     rta_getattr_u8(tb[IFLA_BRPORT_MCAST_TO_UCAST]));
 
 	if (tb[IFLA_BRPORT_NEIGH_SUPPRESS])
-		_print_onoff(f, "neigh_suppress", "neigh_suppress",
+		print_on_off(PRINT_ANY, "neigh_suppress", "neigh_suppress %s ",
 			     rta_getattr_u8(tb[IFLA_BRPORT_NEIGH_SUPPRESS]));
 
 	if (tb[IFLA_BRPORT_GROUP_FWD_MASK]) {
@@ -279,11 +271,11 @@ static void bridge_slave_print_opt(struct link_util *lu, FILE *f,
 	}
 
 	if (tb[IFLA_BRPORT_VLAN_TUNNEL])
-		_print_onoff(f, "vlan_tunnel", "vlan_tunnel",
+		print_on_off(PRINT_ANY, "vlan_tunnel", "vlan_tunnel %s ",
 			     rta_getattr_u8(tb[IFLA_BRPORT_VLAN_TUNNEL]));
 
 	if (tb[IFLA_BRPORT_ISOLATED])
-		_print_onoff(f, "isolated", "isolated",
+		print_on_off(PRINT_ANY, "isolated", "isolated %s ",
 			     rta_getattr_u8(tb[IFLA_BRPORT_ISOLATED]));
 
 	if (tb[IFLA_BRPORT_BACKUP_PORT]) {
-- 
2.25.1


  parent reply	other threads:[~2020-11-14 22:54 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-14 22:53 [PATCH iproute2-next 0/7] Convert a number of use-cases to parse_on_off(), print_on_off() Petr Machata
2020-11-14 22:53 ` [PATCH iproute2-next 1/7] bridge: link: Port over to parse_on_off() Petr Machata
2020-11-14 22:53 ` [PATCH iproute2-next 2/7] bridge: link: Convert to use print_on_off() Petr Machata
2020-11-14 22:53 ` [PATCH iproute2-next 3/7] ip: iplink: Convert to use parse_on_off() Petr Machata
2020-11-14 22:53 ` [PATCH iproute2-next 4/7] ip: iplink_bridge_slave: Port over to parse_on_off() Petr Machata
2020-11-14 22:53 ` Petr Machata [this message]
2020-11-14 22:54 ` [PATCH iproute2-next 6/7] ip: ipnetconf: Convert to use print_on_off() Petr Machata
2020-11-14 22:54 ` [PATCH iproute2-next 7/7] ip: iptuntap: " Petr Machata
2020-11-17  0:56 ` [PATCH iproute2-next 0/7] Convert a number of use-cases to parse_on_off(), print_on_off() David Ahern
2020-11-23 21:21   ` Nikolay Aleksandrov
2020-11-25  4:44 ` David Ahern

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=edde03541654d6dc1a19f2805b34cbea82a85a4f.1605393324.git.me@pmachata.org \
    --to=me@pmachata.org \
    --cc=dsahern@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.