netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: leon@kernel.org
Cc: netdev@vger.kernel.org, Stephen Hemminger <stephen@networkplumber.org>
Subject: [PATCH v2 iproute2 3/6] rdma: make pretty behave like other commands
Date: Wed,  3 Jan 2024 17:13:41 -0800	[thread overview]
Message-ID: <20240104011422.26736-4-stephen@networkplumber.org> (raw)
In-Reply-To: <20240104011422.26736-1-stephen@networkplumber.org>

For tc, ip, etc the -pretty flag only has meaning if json
is used.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 rdma/rdma.c  | 3 +--
 rdma/rdma.h  | 1 -
 rdma/stat.c  | 6 ++----
 rdma/utils.c | 6 ++----
 4 files changed, 5 insertions(+), 11 deletions(-)

diff --git a/rdma/rdma.c b/rdma/rdma.c
index 60ba8c0e5594..bee1985f96d8 100644
--- a/rdma/rdma.c
+++ b/rdma/rdma.c
@@ -115,7 +115,7 @@ int main(int argc, char **argv)
 			       filename, version);
 			return EXIT_SUCCESS;
 		case 'p':
-			pretty = 1;
+			++pretty;
 			break;
 		case 'd':
 			if (show_details)
@@ -153,7 +153,6 @@ int main(int argc, char **argv)
 
 	rd.show_details = show_details;
 	rd.show_driver_details = show_driver_details;
-	rd.pretty_output = pretty;
 	rd.show_raw = show_raw;
 
 	err = rd_init(&rd, filename);
diff --git a/rdma/rdma.h b/rdma/rdma.h
index f6830c851fb1..f9308dbcfafd 100644
--- a/rdma/rdma.h
+++ b/rdma/rdma.h
@@ -68,7 +68,6 @@ struct rd {
 	struct nlmsghdr *nlh;
 	char *buff;
 	json_writer_t *jw;
-	int pretty_output;
 	bool suppress_errors;
 	struct list_head filter_list;
 	char *link_name;
diff --git a/rdma/stat.c b/rdma/stat.c
index 6a3f8ca44892..b428a62ac707 100644
--- a/rdma/stat.c
+++ b/rdma/stat.c
@@ -208,8 +208,7 @@ int res_get_hwcounters(struct rd *rd, struct nlattr *hwc_table, bool print)
 
 		nm = mnl_attr_get_str(hw_line[RDMA_NLDEV_ATTR_STAT_HWCOUNTER_ENTRY_NAME]);
 		v = mnl_attr_get_u64(hw_line[RDMA_NLDEV_ATTR_STAT_HWCOUNTER_ENTRY_VALUE]);
-		if (rd->pretty_output)
-			newline_indent(rd);
+		newline_indent(rd);
 		res_print_u64(rd, nm, v, hw_line[RDMA_NLDEV_ATTR_STAT_HWCOUNTER_ENTRY_NAME]);
 	}
 
@@ -802,8 +801,7 @@ static int do_stat_mode_parse_cb(const struct nlmsghdr *nlh, void *data,
 			} else {
 				print_string(PRINT_FP, NULL, ",", NULL);
 			}
-			if (rd->pretty_output)
-				newline_indent(rd);
+			newline_indent(rd);
 
 			print_string(PRINT_ANY, NULL, "%s", name);
 		}
diff --git a/rdma/utils.c b/rdma/utils.c
index 32e12a64193a..f332b2602e6f 100644
--- a/rdma/utils.c
+++ b/rdma/utils.c
@@ -920,8 +920,7 @@ void print_driver_table(struct rd *rd, struct nlattr *tb)
 	if (!rd->show_driver_details || !tb)
 		return;
 
-	if (rd->pretty_output)
-		newline_indent(rd);
+	newline_indent(rd);
 
 	/*
 	 * Driver attrs are tuples of {key, [print-type], value}.
@@ -933,8 +932,7 @@ void print_driver_table(struct rd *rd, struct nlattr *tb)
 	mnl_attr_for_each_nested(tb_entry, tb) {
 
 		if (cc > MAX_LINE_LENGTH) {
-			if (rd->pretty_output)
-				newline_indent(rd);
+			newline_indent(rd);
 			cc = 0;
 		}
 		if (rd_attr_check(tb_entry, &type) != MNL_CB_OK)
-- 
2.43.0


  parent reply	other threads:[~2024-01-04  1:14 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-04  1:13 [PATCH v2 iproute2 0/6] rdma: print related patches Stephen Hemminger
2024-01-04  1:13 ` [PATCH v2 iproute2 1/6] rdma: shorten print_ lines Stephen Hemminger
2024-01-04 11:28   ` Petr Machata
2024-01-04  1:13 ` [PATCH v2 iproute2 2/6] rdma: use standard flag for json Stephen Hemminger
2024-01-04 12:07   ` Petr Machata
2024-01-04  1:13 ` Stephen Hemminger [this message]
2024-01-04  1:13 ` [PATCH v2 iproute2 4/6] rdma: make supress_errors a bit Stephen Hemminger
2024-01-04 14:17   ` Petr Machata
2024-01-04  1:13 ` [PATCH v2 iproute2 5/6] rdma: add oneline flag Stephen Hemminger
2024-01-04 14:20   ` Petr Machata
2024-01-04  1:13 ` [PATCH v2 iproute2 6/6] rdma: do not mix newline and json object Stephen Hemminger
2024-01-04 14:29   ` Petr Machata
2024-01-04  5:58 ` [PATCH v2 iproute2 0/6] rdma: print related patches Chengchang Tang
2024-01-07  8:20 ` Leon Romanovsky
2024-01-07 17:30 ` patchwork-bot+netdevbpf

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=20240104011422.26736-4-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=leon@kernel.org \
    --cc=netdev@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).