From: Sidong Yang <realwakka@gmail.com>
To: dsterba@suse.cz, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH v2 1/2] btrfs-progs: common: introduce fmt_print_start_object
Date: Fri, 11 Dec 2020 16:11:50 +0000 [thread overview]
Message-ID: <20201211161150.GA456927@realwakka> (raw)
In-Reply-To: <20201210202846.GI6430@twin.jikos.cz>
On Thu, Dec 10, 2020 at 09:28:47PM +0100, David Sterba wrote:
> On Wed, Nov 11, 2020 at 04:39:08PM +0000, Sidong Yang wrote:
> > Introduce a new function that can be used when you need to print an json
> > object in command like "device stats".
> >
> > Signed-off-by: Sidong Yang <realwakka@gmail.com>
> > ---
> > common/format-output.c | 20 ++++++++++++++++++++
> > common/format-output.h | 3 +++
> > 2 files changed, 23 insertions(+)
> >
> > diff --git a/common/format-output.c b/common/format-output.c
> > index 8df93ecb..f31e7259 100644
> > --- a/common/format-output.c
> > +++ b/common/format-output.c
> > @@ -213,6 +213,26 @@ void fmt_print_end_group(struct format_ctx *fctx, const char *name)
> > }
> > }
> >
> > +void fmt_print_start_object(struct format_ctx *fctx)
> > +{
> > + if (bconf.output_format == CMD_FORMAT_JSON) {
> > + fmt_separator(fctx);
> > + fmt_inc_depth(fctx);
> > + fctx->memb[fctx->depth] = 0;
> > + putchar('{');
> > + }
> > +}
Hi David. Thanks for review.
>
> This duplicates what fmt_print_start_group and fmt_print_end_group do,
> so these should be extended to handle when 'name' is NULL and print only
> the [ or {.
I think it's good to extend fmt_print_start_group. I'll retry with it.
Thanks,
Sidong
prev parent reply other threads:[~2020-12-11 17:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-11 16:39 [PATCH v2 1/2] btrfs-progs: common: introduce fmt_print_start_object Sidong Yang
2020-11-11 16:39 ` [PATCH v2 2/2] btrfs-progs: device stats: add json output format Sidong Yang
2020-12-10 20:53 ` David Sterba
2021-02-16 10:21 ` Filipe Manana
2020-12-10 20:28 ` [PATCH v2 1/2] btrfs-progs: common: introduce fmt_print_start_object David Sterba
2020-12-11 16:11 ` Sidong Yang [this message]
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=20201211161150.GA456927@realwakka \
--to=realwakka@gmail.com \
--cc=dsterba@suse.cz \
--cc=linux-btrfs@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).