diff mbox series

[iproute2-next,6/7] tc/action: remove unused args from tc_print_action

Message ID 20240413220516.7235-7-stephen@networkplumber.org (mailing list archive)
State Changes Requested
Delegated to: David Ahern
Headers show
Series unused arguments | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Stephen Hemminger April 13, 2024, 10:04 p.m. UTC
The file handle is not used, and total actions is always zero.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 tc/f_basic.c    |  2 +-
 tc/f_bpf.c      |  2 +-
 tc/f_cgroup.c   |  2 +-
 tc/f_flow.c     |  2 +-
 tc/f_flower.c   |  2 +-
 tc/f_fw.c       |  2 +-
 tc/f_matchall.c |  2 +-
 tc/f_route.c    |  2 +-
 tc/f_u32.c      |  2 +-
 tc/m_action.c   | 28 +++++++++++++++-------------
 tc/tc_util.h    |  2 +-
 11 files changed, 25 insertions(+), 23 deletions(-)
diff mbox series

Patch

diff --git a/tc/f_basic.c b/tc/f_basic.c
index 6b36028f..b76092c6 100644
--- a/tc/f_basic.c
+++ b/tc/f_basic.c
@@ -134,7 +134,7 @@  static int basic_print_opt(struct filter_util *qu, FILE *f,
 	}
 
 	if (tb[TCA_BASIC_ACT]) {
-		tc_print_action(f, tb[TCA_BASIC_ACT], 0);
+		tc_print_action(tb[TCA_BASIC_ACT]);
 	}
 
 	return 0;
diff --git a/tc/f_bpf.c b/tc/f_bpf.c
index f265249d..ad40bc99 100644
--- a/tc/f_bpf.c
+++ b/tc/f_bpf.c
@@ -254,7 +254,7 @@  static int bpf_print_opt(struct filter_util *qu, FILE *f,
 	}
 
 	if (tb[TCA_BPF_ACT])
-		tc_print_action(f, tb[TCA_BPF_ACT], 0);
+		tc_print_action(tb[TCA_BPF_ACT]);
 
 	return 0;
 }
diff --git a/tc/f_cgroup.c b/tc/f_cgroup.c
index d4201b91..ed7638ed 100644
--- a/tc/f_cgroup.c
+++ b/tc/f_cgroup.c
@@ -97,7 +97,7 @@  static int cgroup_print_opt(struct filter_util *qu, FILE *f,
 	}
 
 	if (tb[TCA_CGROUP_ACT])
-		tc_print_action(f, tb[TCA_CGROUP_ACT], 0);
+		tc_print_action(tb[TCA_CGROUP_ACT]);
 
 	return 0;
 }
diff --git a/tc/f_flow.c b/tc/f_flow.c
index 07340f2a..0e27d216 100644
--- a/tc/f_flow.c
+++ b/tc/f_flow.c
@@ -350,7 +350,7 @@  static int flow_print_opt(struct filter_util *fu, FILE *f, struct rtattr *opt,
 		tc_print_police(tb[TCA_FLOW_POLICE]);
 	if (tb[TCA_FLOW_ACT]) {
 		print_nl();
-		tc_print_action(f, tb[TCA_FLOW_ACT], 0);
+		tc_print_action(tb[TCA_FLOW_ACT]);
 	}
 	return 0;
 }
diff --git a/tc/f_flower.c b/tc/f_flower.c
index 53188f1c..1d2cff46 100644
--- a/tc/f_flower.c
+++ b/tc/f_flower.c
@@ -3178,7 +3178,7 @@  static int flower_print_opt(struct filter_util *qu, FILE *f,
 	}
 
 	if (tb[TCA_FLOWER_ACT])
-		tc_print_action(f, tb[TCA_FLOWER_ACT], 0);
+		tc_print_action(tb[TCA_FLOWER_ACT]);
 
 	return 0;
 }
diff --git a/tc/f_fw.c b/tc/f_fw.c
index 190f79fc..80809f13 100644
--- a/tc/f_fw.c
+++ b/tc/f_fw.c
@@ -156,7 +156,7 @@  static int fw_print_opt(struct filter_util *qu, FILE *f, struct rtattr *opt, __u
 
 	if (tb[TCA_FW_ACT]) {
 		print_nl();
-		tc_print_action(f, tb[TCA_FW_ACT], 0);
+		tc_print_action(tb[TCA_FW_ACT]);
 	}
 	return 0;
 }
diff --git a/tc/f_matchall.c b/tc/f_matchall.c
index 38b68d7e..2ecf028b 100644
--- a/tc/f_matchall.c
+++ b/tc/f_matchall.c
@@ -155,7 +155,7 @@  static int matchall_print_opt(struct filter_util *qu, FILE *f,
 
 
 	if (tb[TCA_MATCHALL_ACT])
-		tc_print_action(f, tb[TCA_MATCHALL_ACT], 0);
+		tc_print_action(tb[TCA_MATCHALL_ACT]);
 
 	return 0;
 }
diff --git a/tc/f_route.c b/tc/f_route.c
index 3b6f5c2f..0af2fde1 100644
--- a/tc/f_route.c
+++ b/tc/f_route.c
@@ -167,7 +167,7 @@  static int route_print_opt(struct filter_util *qu, FILE *f, struct rtattr *opt,
 	if (tb[TCA_ROUTE4_POLICE])
 		tc_print_police(tb[TCA_ROUTE4_POLICE]);
 	if (tb[TCA_ROUTE4_ACT])
-		tc_print_action(f, tb[TCA_ROUTE4_ACT], 0);
+		tc_print_action(tb[TCA_ROUTE4_ACT]);
 	return 0;
 }
 
diff --git a/tc/f_u32.c b/tc/f_u32.c
index c04ec02d..6e2e00b1 100644
--- a/tc/f_u32.c
+++ b/tc/f_u32.c
@@ -1377,7 +1377,7 @@  static int u32_print_opt(struct filter_util *qu, FILE *f, struct rtattr *opt,
 	}
 
 	if (tb[TCA_U32_ACT])
-		tc_print_action(f, tb[TCA_U32_ACT], 0);
+		tc_print_action(tb[TCA_U32_ACT]);
 
 	return 0;
 }
diff --git a/tc/m_action.c b/tc/m_action.c
index feb869a9..6910562e 100644
--- a/tc/m_action.c
+++ b/tc/m_action.c
@@ -41,7 +41,7 @@  static void act_usage(void)
 	 */
 	fprintf(stderr,
 		"usage: tc actions <ACTSPECOP>*\n"
-		"Where: 	ACTSPECOP := ACR | GD | FL\n"
+		"Where:		ACTSPECOP := ACR | GD | FL\n"
 		"	ACR := add | change | replace <ACTSPEC>*\n"
 		"	GD := get | delete | <ACTISPEC>*\n"
 		"	FL := ls | list | flush | <ACTNAMESPEC>\n"
@@ -360,7 +360,7 @@  bad_val:
 	return -1;
 }
 
-static int tc_print_one_action(FILE *f, struct rtattr *arg, bool bind)
+static int tc_print_one_action(struct rtattr *arg, bool bind)
 {
 
 	struct rtattr *tb[TCA_ACT_MAX + 1];
@@ -382,7 +382,7 @@  static int tc_print_one_action(FILE *f, struct rtattr *arg, bool bind)
 	if (a == NULL)
 		return err;
 
-	err = a->print_aopt(a, f, tb[TCA_ACT_OPTIONS]);
+	err = a->print_aopt(a, stdout, tb[TCA_ACT_OPTIONS]);
 
 	if (err < 0)
 		return err;
@@ -466,7 +466,7 @@  static int tc_print_one_action(FILE *f, struct rtattr *arg, bool bind)
 }
 
 static int
-tc_print_action_flush(FILE *f, const struct rtattr *arg)
+tc_print_action_flush(const struct rtattr *arg)
 {
 
 	struct rtattr *tb[TCA_MAX + 1];
@@ -486,16 +486,18 @@  tc_print_action_flush(FILE *f, const struct rtattr *arg)
 		return err;
 
 	delete_count = RTA_DATA(tb[TCA_FCNT]);
-	fprintf(f, " %s (%d entries)\n", a->id, *delete_count);
+	print_string(PRINT_FP, NULL, " %s ", a->id);
+	open_json_object(a->id);
+	print_int(PRINT_ANY, "entries",  "(%d entries)\n", *delete_count);
+	close_json_object();
+
 	tab_flush = 0;
 	return 0;
 }
 
 static int
-tc_dump_action(FILE *f, const struct rtattr *arg, unsigned short tot_acts,
-	       bool bind)
+tc_dump_action(const struct rtattr *arg, unsigned short tot_acts, bool bind)
 {
-
 	int i;
 
 	if (arg == NULL)
@@ -509,7 +511,7 @@  tc_dump_action(FILE *f, const struct rtattr *arg, unsigned short tot_acts,
 	parse_rtattr_nested(tb, tot_acts, arg);
 
 	if (tab_flush && tb[0] && !tb[1])
-		return tc_print_action_flush(f, tb[0]);
+		return tc_print_action_flush(tb[0]);
 
 	open_json_array(PRINT_JSON, "actions");
 	for (i = 0; i <= tot_acts; i++) {
@@ -518,7 +520,7 @@  tc_dump_action(FILE *f, const struct rtattr *arg, unsigned short tot_acts,
 			print_nl();
 			print_uint(PRINT_ANY, "order",
 				   "\taction order %u: ", i);
-			if (tc_print_one_action(f, tb[i], bind) < 0)
+			if (tc_print_one_action(tb[i], bind) < 0)
 				fprintf(stderr, "Error printing action\n");
 			close_json_object();
 		}
@@ -530,9 +532,9 @@  tc_dump_action(FILE *f, const struct rtattr *arg, unsigned short tot_acts,
 }
 
 int
-tc_print_action(FILE *f, const struct rtattr *arg, unsigned short tot_acts)
+tc_print_action(const struct rtattr *arg)
 {
-	return tc_dump_action(f, arg, tot_acts, true);
+	return tc_dump_action(arg, 0, true);
 }
 
 int print_action(struct nlmsghdr *n, void *arg)
@@ -585,7 +587,7 @@  int print_action(struct nlmsghdr *n, void *arg)
 	}
 
 	open_json_object(NULL);
-	tc_dump_action(fp, tb[TCA_ACT_TAB], tot_acts ? *tot_acts:0, false);
+	tc_dump_action(tb[TCA_ACT_TAB], tot_acts ? *tot_acts : 0, false);
 
 	if (tb[TCA_ROOT_EXT_WARN_MSG]) {
 		print_string(PRINT_ANY, "warn", "%s",
diff --git a/tc/tc_util.h b/tc/tc_util.h
index 2d38dd58..a1137bc2 100644
--- a/tc/tc_util.h
+++ b/tc/tc_util.h
@@ -110,7 +110,7 @@  int parse_action_control_slash(int *argc_p, char ***argv_p,
 			       int *result1_p, int *result2_p, bool allow_num);
 void print_action_control(const char *prefix, int action, const char *suffix);
 int police_print_xstats(struct action_util *a, FILE *f, struct rtattr *tb);
-int tc_print_action(FILE *f, const struct rtattr *tb, unsigned short tot_acts);
+int tc_print_action(const struct rtattr *tb);
 int parse_action(int *argc_p, char ***argv_p, int tca_id, struct nlmsghdr *n);
 void print_tm(const struct tcf_t *tm);
 int prio_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt);