From: Petr Machata <me@pmachata.org>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: leon@kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH v2 iproute2 2/6] rdma: use standard flag for json
Date: Thu, 04 Jan 2024 13:07:38 +0100 [thread overview]
Message-ID: <874jft6v4b.fsf@nvidia.com> (raw)
In-Reply-To: <20240104011422.26736-3-stephen@networkplumber.org>
Stephen Hemminger <stephen@networkplumber.org> writes:
> The other iproute2 utils use variable json as flag.
Some do, some don't. dcb, devlink, rdma do not, the rest do.
Personally I'm not a fan of global state, and consider this patch to be
a step back in terms of best practices. I do realize this is how it's
done in iproute2. To the point that utils.h actually carries external
declarations for these variables. But to me those are inevitable warts,
not something to embrace and extend.
Objectively... whatever. There's only one instance of the context
structure anyway. It's just the overtones of a quick hack that irk me.
Anyway, the mechanical parts of the conversion look OK. But:
> diff --git a/rdma/stat.c b/rdma/stat.c
> index 28b1ad857219..6a3f8ca44892 100644
> --- a/rdma/stat.c
> +++ b/rdma/stat.c
> @@ -208,7 +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 && !rd->json_output)
> + if (rd->pretty_output)
> newline_indent(rd);
newline_indent() issues close_json_object(). Previously it wouldn't be
invoked in JSON mode, now it will be. Doesn't this break JSON output?
Same question for the hunk below.
> res_print_u64(rd, nm, v, hw_line[RDMA_NLDEV_ATTR_STAT_HWCOUNTER_ENTRY_NAME]);
> }
> @@ -802,7 +802,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 && !rd->json_output)
> + if (rd->pretty_output)
> newline_indent(rd);
>
> print_string(PRINT_ANY, NULL, "%s", name);
next prev parent reply other threads:[~2024-01-04 14:17 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 [this message]
2024-01-04 1:13 ` [PATCH v2 iproute2 3/6] rdma: make pretty behave like other commands Stephen Hemminger
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=874jft6v4b.fsf@nvidia.com \
--to=me@pmachata.org \
--cc=leon@kernel.org \
--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 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).