[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <99fbc115-c865-c4f8-31d6-9cd157646481@huawei.com>
Date: Wed, 3 Jan 2024 11:40:52 +0800
From: Chengchang Tang <tangchengchang@...wei.com>
To: Stephen Hemminger <stephen@...workplumber.org>, <leon@...nel.org>
CC: <netdev@...r.kernel.org>
Subject: Re: [RFC iproute2 6/8] rdma: do not mix newline and json object
On 2024/1/3 8:34, Stephen Hemminger wrote:
> Mixing the semantics of ending lines with the json object
> leads to several bugs where json object is closed twice, etc.
> Replace by breaking the meaning of newline() function into
> two parts.
These codes fix the issue mentioned in:
https://lore.kernel.org/netdev/20231229065241.554726-1-huangjunxian6@hisilicon.com/T/#m5476970400a2d6f2b9b8f3f369d8a26b9663d4b9
Might it need a fixes ?
Fixes: 331152752a97 ("rdma: print driver resource attributes")
> Signed-off-by: Stephen Hemminger <stephen@...workplumber.org>
> ---
> rdma/dev.c | 3 ++-
> rdma/link.c | 4 +++-
> rdma/rdma.h | 5 +++--
> rdma/res-cmid.c | 3 ++-
> rdma/res-cq.c | 7 +++++--
> rdma/res-ctx.c | 3 ++-
> rdma/res-mr.c | 6 ++++--
> rdma/res-pd.c | 4 ++--
> rdma/res-qp.c | 6 ++++--
> rdma/res-srq.c | 6 ++++--
> rdma/res.c | 4 +++-
> rdma/stat-mr.c | 3 ++-
> rdma/stat.c | 17 ++++++++++-------
> rdma/utils.c | 16 +++++-----------
> 14 files changed, 51 insertions(+), 36 deletions(-)
>
> diff --git a/rdma/dev.c b/rdma/dev.c
> index 31868c6fe43e..c8cb6d675c3b 100644
>
< ... >
> index aeb627be7715..64f598c5aa8f 100644
> --- a/rdma/utils.c
> +++ b/rdma/utils.c
> @@ -771,16 +771,10 @@ struct dev_map *dev_map_lookup(struct rd *rd, bool allow_port_index)
>
> #define nla_type(attr) ((attr)->nla_type & NLA_TYPE_MASK)
>
> -void newline(struct rd *rd)
> +void print_nl_indent(void)
> {
> - close_json_object();
> - print_nl();
> -}
> -
> -void newline_indent(struct rd *rd)
> -{
> - newline(rd);
> - print_string(PRINT_FP, NULL, " ", NULL);
> + if (!is_json_context())
> + printf("%s ", _SL_);
> }
>
> static int print_driver_string(struct rd *rd, const char *key_str,
> @@ -920,7 +914,7 @@ void print_driver_table(struct rd *rd, struct nlattr *tb)
> if (!rd->show_driver_details || !tb)
> return;
>
> - newline_indent(rd);
> + print_nl_indent();
>
> /*
> * Driver attrs are tuples of {key, [print-type], value}.
> @@ -932,7 +926,7 @@ void print_driver_table(struct rd *rd, struct nlattr *tb)
> mnl_attr_for_each_nested(tb_entry, tb) {
>
> if (cc > MAX_LINE_LENGTH) {
> - newline_indent(rd);
> + print_nl_indent();
> cc = 0;
> }
> if (rd_attr_check(tb_entry, &type) != MNL_CB_OK)
Powered by blists - more mailing lists