[PATCH v3 iproute2 2/4] bridge: Remove duplicated textification macros

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



include/utils.h already provides textify(), which is functionally
equivalent to __stringify().

Signed-off-by: Tobias Waldekranz <tobias@xxxxxxxxxxxxxx>
---
 bridge/vlan.c | 41 +++++++++++++++++++----------------------
 bridge/vni.c  | 15 ++++++---------
 2 files changed, 25 insertions(+), 31 deletions(-)

diff --git a/bridge/vlan.c b/bridge/vlan.c
index 0a7e6c45..70f01aff 100644
--- a/bridge/vlan.c
+++ b/bridge/vlan.c
@@ -28,9 +28,6 @@ enum vlan_show_subject {
 
 #define VLAN_ID_LEN 9
 
-#define __stringify_1(x...) #x
-#define __stringify(x...) __stringify_1(x)
-
 static void usage(void)
 {
 	fprintf(stderr,
@@ -579,7 +576,7 @@ static void open_vlan_port(int ifi_index, enum vlan_show_subject subject)
 {
 	open_json_object(NULL);
 	print_color_string(PRINT_ANY, COLOR_IFNAME, "ifname",
-			   "%-" __stringify(IFNAMSIZ) "s  ",
+			   "%-" textify(IFNAMSIZ) "s  ",
 			   ll_index_to_name(ifi_index));
 	open_json_array(PRINT_JSON,
 			subject == VLAN_SHOW_VLAN ? "vlans": "tunnels");
@@ -643,7 +640,7 @@ static void print_vlan_tunnel_info(struct rtattr *tb, int ifindex)
 			opened = true;
 		} else {
 			print_string(PRINT_FP, NULL,
-				     "%-" __stringify(IFNAMSIZ) "s  ", "");
+				     "%-" textify(IFNAMSIZ) "s  ", "");
 		}
 
 		open_json_object(NULL);
@@ -716,13 +713,13 @@ static void print_vlan_flags(__u16 flags)
 
 static void __print_one_vlan_stats(const struct bridge_vlan_xstats *vstats)
 {
-	print_string(PRINT_FP, NULL, "%-" __stringify(IFNAMSIZ) "s    ", "");
+	print_string(PRINT_FP, NULL, "%-" textify(IFNAMSIZ) "s    ", "");
 	print_lluint(PRINT_ANY, "rx_bytes", "RX: %llu bytes",
 		     vstats->rx_bytes);
 	print_lluint(PRINT_ANY, "rx_packets", " %llu packets\n",
 		     vstats->rx_packets);
 
-	print_string(PRINT_FP, NULL, "%-" __stringify(IFNAMSIZ) "s    ", "");
+	print_string(PRINT_FP, NULL, "%-" textify(IFNAMSIZ) "s    ", "");
 	print_lluint(PRINT_ANY, "tx_bytes", "TX: %llu bytes",
 		     vstats->tx_bytes);
 	print_lluint(PRINT_ANY, "tx_packets", " %llu packets\n",
@@ -776,7 +773,7 @@ static void print_vlan_stats_attr(struct rtattr *attr, int ifindex)
 			found_vlan = true;
 		} else {
 			print_string(PRINT_FP, NULL,
-				     "%-" __stringify(IFNAMSIZ) "s  ", "");
+				     "%-" textify(IFNAMSIZ) "s  ", "");
 		}
 		print_one_vlan_stats(vstats);
 	}
@@ -822,7 +819,7 @@ static void print_vlan_router_ports(struct rtattr *rattr)
 	int rem = RTA_PAYLOAD(rattr);
 	struct rtattr *i;
 
-	print_string(PRINT_FP, NULL, "%-" __stringify(IFNAMSIZ) "s    ", "");
+	print_string(PRINT_FP, NULL, "%-" textify(IFNAMSIZ) "s    ", "");
 	open_json_array(PRINT_ANY, is_json_context() ? "router_ports" :
 						       "router ports: ");
 	for (i = RTA_DATA(rattr); RTA_OK(i, rem); i = RTA_NEXT(i, rem)) {
@@ -834,7 +831,7 @@ static void print_vlan_router_ports(struct rtattr *rattr)
 			print_nl();
 			/* start: IFNAMSIZ + 4 + strlen("router ports: ") */
 			print_string(PRINT_FP, NULL,
-				     "%-" __stringify(IFNAMSIZ) "s    "
+				     "%-" textify(IFNAMSIZ) "s    "
 				     "              ",
 				     "");
 		}
@@ -872,11 +869,11 @@ static void print_vlan_global_opts(struct rtattr *a, int ifindex)
 		vlan_rtm_cur_ifidx = ifindex;
 	} else {
 		open_json_object(NULL);
-		print_string(PRINT_FP, NULL, "%-" __stringify(IFNAMSIZ) "s  ", "");
+		print_string(PRINT_FP, NULL, "%-" textify(IFNAMSIZ) "s  ", "");
 	}
 	print_range("vlan", vid, vrange);
 	print_nl();
-	print_string(PRINT_FP, NULL, "%-" __stringify(IFNAMSIZ) "s    ", "");
+	print_string(PRINT_FP, NULL, "%-" textify(IFNAMSIZ) "s    ", "");
 	if (vtb[BRIDGE_VLANDB_GOPTS_MCAST_SNOOPING]) {
 		vattr = vtb[BRIDGE_VLANDB_GOPTS_MCAST_SNOOPING];
 		print_uint(PRINT_ANY, "mcast_snooping", "mcast_snooping %u ",
@@ -1012,12 +1009,12 @@ static void print_vlan_opts(struct rtattr *a, int ifindex)
 		vlan_rtm_cur_ifidx = ifindex;
 	} else {
 		open_json_object(NULL);
-		print_string(PRINT_FP, NULL, "%-" __stringify(IFNAMSIZ) "s  ", "");
+		print_string(PRINT_FP, NULL, "%-" textify(IFNAMSIZ) "s  ", "");
 	}
 	print_range("vlan", vinfo->vid, vrange);
 	print_vlan_flags(vinfo->flags);
 	print_nl();
-	print_string(PRINT_FP, NULL, "%-" __stringify(IFNAMSIZ) "s    ", "");
+	print_string(PRINT_FP, NULL, "%-" textify(IFNAMSIZ) "s    ", "");
 	print_stp_state(state);
 	if (vtb[BRIDGE_VLANDB_ENTRY_MCAST_ROUTER]) {
 		vattr = vtb[BRIDGE_VLANDB_ENTRY_MCAST_ROUTER];
@@ -1155,8 +1152,8 @@ static int vlan_show(int argc, char **argv, int subject)
 		}
 
 		if (!is_json_context()) {
-			printf("%-" __stringify(IFNAMSIZ) "s  %-"
-			       __stringify(VLAN_ID_LEN) "s", "port",
+			printf("%-" textify(IFNAMSIZ) "s  %-"
+			       textify(VLAN_ID_LEN) "s", "port",
 			       "vlan-id");
 			printf("\n");
 		}
@@ -1183,8 +1180,8 @@ static int vlan_show(int argc, char **argv, int subject)
 		}
 
 		if (!is_json_context()) {
-			printf("%-" __stringify(IFNAMSIZ) "s  %-"
-			       __stringify(VLAN_ID_LEN) "s", "port",
+			printf("%-" textify(IFNAMSIZ) "s  %-"
+			       textify(VLAN_ID_LEN) "s", "port",
 			       "vlan-id");
 			if (subject == VLAN_SHOW_TUNNELINFO)
 				printf("  tunnel-id");
@@ -1207,7 +1204,7 @@ static int vlan_show(int argc, char **argv, int subject)
 		}
 
 		if (!is_json_context())
-			printf("%-" __stringify(IFNAMSIZ) "s  vlan-id\n",
+			printf("%-" textify(IFNAMSIZ) "s  vlan-id\n",
 			       "port");
 
 		if (rtnl_dump_filter(&rth, print_vlan_stats, stdout) < 0) {
@@ -1269,8 +1266,8 @@ static int vlan_global_show(int argc, char **argv)
 	}
 
 	if (!is_json_context()) {
-		printf("%-" __stringify(IFNAMSIZ) "s  %-"
-		       __stringify(VLAN_ID_LEN) "s", "port",
+		printf("%-" textify(IFNAMSIZ) "s  %-"
+		       textify(VLAN_ID_LEN) "s", "port",
 		       "vlan-id");
 		printf("\n");
 	}
@@ -1318,7 +1315,7 @@ static void print_vlan_info(struct rtattr *tb, int ifindex)
 			opened = true;
 		} else {
 			print_string(PRINT_FP, NULL, "%-"
-				     __stringify(IFNAMSIZ) "s  ", "");
+				     textify(IFNAMSIZ) "s  ", "");
 		}
 
 		open_json_object(NULL);
diff --git a/bridge/vni.c b/bridge/vni.c
index e1f981fc..57b04c8c 100644
--- a/bridge/vni.c
+++ b/bridge/vni.c
@@ -27,9 +27,6 @@ static unsigned int filter_index;
 /* max len of "<start>-<end>" */
 #define VXLAN_ID_LEN 17
 
-#define __stringify_1(x...) #x
-#define __stringify(x...) __stringify_1(x)
-
 static void usage(void)
 {
 	fprintf(stderr,
@@ -153,7 +150,7 @@ static void open_vni_port(int ifi_index)
 {
 	open_json_object(NULL);
 	print_color_string(PRINT_ANY, COLOR_IFNAME, "ifname",
-			   "%-" __stringify(IFNAMSIZ) "s  ",
+			   "%-" textify(IFNAMSIZ) "s  ",
 			   ll_index_to_name(ifi_index));
 	open_json_array(PRINT_JSON, "vnis");
 }
@@ -174,7 +171,7 @@ static void print_vnifilter_entry_stats(struct rtattr *stats_attr)
 			   RTA_PAYLOAD(stats_attr), NLA_F_NESTED);
 
 	print_nl();
-	print_string(PRINT_FP, NULL, "%-" __stringify(IFNAMSIZ) "s    RX: ",
+	print_string(PRINT_FP, NULL, "%-" textify(IFNAMSIZ) "s    RX: ",
 		     "");
 
 	if (stb[VNIFILTER_ENTRY_STATS_RX_BYTES]) {
@@ -195,7 +192,7 @@ static void print_vnifilter_entry_stats(struct rtattr *stats_attr)
 	}
 
 	print_nl();
-	print_string(PRINT_FP, NULL, "%-" __stringify(IFNAMSIZ) "s    TX: ",
+	print_string(PRINT_FP, NULL, "%-" textify(IFNAMSIZ) "s    TX: ",
 		     "");
 
 	if (stb[VNIFILTER_ENTRY_STATS_TX_BYTES]) {
@@ -327,7 +324,7 @@ int print_vnifilter_rtm(struct nlmsghdr *n, void *arg)
 			open_vni_port(tmsg->ifindex);
 			opened = true;
 		} else {
-			print_string(PRINT_FP, NULL, "%-" __stringify(IFNAMSIZ) "s  ", "");
+			print_string(PRINT_FP, NULL, "%-" textify(IFNAMSIZ) "s  ", "");
 		}
 
 		print_vni(t, tmsg->ifindex);
@@ -373,8 +370,8 @@ static int vni_show(int argc, char **argv)
 	}
 
 	if (!is_json_context())
-		printf("%-" __stringify(IFNAMSIZ) "s  %-"
-		       __stringify(VXLAN_ID_LEN) "s  group/remote\n", "dev",
+		printf("%-" textify(IFNAMSIZ) "s  %-"
+		       textify(VXLAN_ID_LEN) "s  group/remote\n", "dev",
 		       "vni");
 
 	ret = rtnl_dump_filter(&rth, print_vnifilter_rtm, NULL);
-- 
2.34.1





[Index of Archives]     [Netdev]     [AoE Tools]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]     [Video 4 Linux]

  Powered by Linux