* [RFC] btrfs-progs: format-output: remove newline in fmt_end text mode @ 2021-02-16 16:28 Sidong Yang 2021-02-17 10:57 ` Filipe Manana 2021-02-19 21:56 ` David Sterba 0 siblings, 2 replies; 5+ messages in thread From: Sidong Yang @ 2021-02-16 16:28 UTC (permalink / raw) To: linux-btrfs, dsterba, Filipe Manana; +Cc: Sidong Yang Remove a code that inserting new line in fmt_end() for text mode. Old code made a failure in fstest btrfs/006. Signed-off-by: Sidong Yang <realwakka@gmail.com> --- Hi, I've just read mail that Filipe written that some failure about fstest. I'm worried about this patch makes other problem. So make it RFC. Thanks. --- common/format-output.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/common/format-output.c b/common/format-output.c index f5b12548..96e0dfef 100644 --- a/common/format-output.c +++ b/common/format-output.c @@ -124,9 +124,7 @@ void fmt_end(struct format_ctx *fctx) /* Close, no continuation to print */ - if (bconf.output_format & CMD_FORMAT_TEXT) - putchar('\n'); - else if (bconf.output_format & CMD_FORMAT_JSON) { + if (bconf.output_format & CMD_FORMAT_JSON) { fmt_dec_depth(fctx); fmt_separator(fctx); printf("}\n"); -- 2.25.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [RFC] btrfs-progs: format-output: remove newline in fmt_end text mode 2021-02-16 16:28 [RFC] btrfs-progs: format-output: remove newline in fmt_end text mode Sidong Yang @ 2021-02-17 10:57 ` Filipe Manana 2021-02-19 21:56 ` David Sterba 1 sibling, 0 replies; 5+ messages in thread From: Filipe Manana @ 2021-02-17 10:57 UTC (permalink / raw) To: Sidong Yang; +Cc: linux-btrfs, dsterba On Tue, Feb 16, 2021 at 4:28 PM Sidong Yang <realwakka@gmail.com> wrote: > > Remove a code that inserting new line in fmt_end() for text mode. > Old code made a failure in fstest btrfs/006. > > Signed-off-by: Sidong Yang <realwakka@gmail.com> > --- > Hi, I've just read mail that Filipe written that some failure about fstest. > I'm worried about this patch makes other problem. So make it RFC. Thanks. Fixes the test failure indeed, thanks! > --- > common/format-output.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/common/format-output.c b/common/format-output.c > index f5b12548..96e0dfef 100644 > --- a/common/format-output.c > +++ b/common/format-output.c > @@ -124,9 +124,7 @@ void fmt_end(struct format_ctx *fctx) > > /* Close, no continuation to print */ > > - if (bconf.output_format & CMD_FORMAT_TEXT) > - putchar('\n'); > - else if (bconf.output_format & CMD_FORMAT_JSON) { > + if (bconf.output_format & CMD_FORMAT_JSON) { > fmt_dec_depth(fctx); > fmt_separator(fctx); > printf("}\n"); > -- > 2.25.1 > -- Filipe David Manana, “Whether you think you can, or you think you can't — you're right.” ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC] btrfs-progs: format-output: remove newline in fmt_end text mode 2021-02-16 16:28 [RFC] btrfs-progs: format-output: remove newline in fmt_end text mode Sidong Yang 2021-02-17 10:57 ` Filipe Manana @ 2021-02-19 21:56 ` David Sterba 2021-02-20 16:42 ` Sidong Yang 1 sibling, 1 reply; 5+ messages in thread From: David Sterba @ 2021-02-19 21:56 UTC (permalink / raw) To: Sidong Yang; +Cc: linux-btrfs, dsterba, Filipe Manana On Tue, Feb 16, 2021 at 04:28:40PM +0000, Sidong Yang wrote: > Remove a code that inserting new line in fmt_end() for text mode. > Old code made a failure in fstest btrfs/006. > > Signed-off-by: Sidong Yang <realwakka@gmail.com> > --- > Hi, I've just read mail that Filipe written that some failure about fstest. > I'm worried about this patch makes other problem. So make it RFC. Thanks. I found the discussion under the device stats patch adding json, the added line was known and "hopefully not causing problems", but the fstests seem to notice. I think we can fix that by removing the fmt_end newline but we also need to update how the fmt_print is done for the text output. Ie. for json there are some strict rules for line continuations (",") but for the textual output, each line ended by "\n" right away, without delaying that to the next fmt_* call should work. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC] btrfs-progs: format-output: remove newline in fmt_end text mode 2021-02-19 21:56 ` David Sterba @ 2021-02-20 16:42 ` Sidong Yang 2021-02-22 15:46 ` David Sterba 0 siblings, 1 reply; 5+ messages in thread From: Sidong Yang @ 2021-02-20 16:42 UTC (permalink / raw) To: dsterba, linux-btrfs, Filipe Manana On Fri, Feb 19, 2021 at 10:56:11PM +0100, David Sterba wrote: > On Tue, Feb 16, 2021 at 04:28:40PM +0000, Sidong Yang wrote: > > Remove a code that inserting new line in fmt_end() for text mode. > > Old code made a failure in fstest btrfs/006. > > > > Signed-off-by: Sidong Yang <realwakka@gmail.com> > > --- > > Hi, I've just read mail that Filipe written that some failure about fstest. > > I'm worried about this patch makes other problem. So make it RFC. Thanks. > > I found the discussion under the device stats patch adding json, the > added line was known and "hopefully not causing problems", but the > fstests seem to notice. > > I think we can fix that by removing the fmt_end newline but we also need > to update how the fmt_print is done for the text output. Ie. for json > there are some strict rules for line continuations (",") but for the > textual output, each line ended by "\n" right away, without delaying > that to the next fmt_* call should work. You mean that if this patch applied and the code prints device stats for text format manually replaced to fmt_print(), there is no last new line for text output? fmt_print() prints new line before print some value now. I think that it should prints new line at the end of each fmt_print(). like below diff --git a/common/format-output.c b/common/format-output.c index f5b12548..9a9f5bf7 100644 --- a/common/format-output.c +++ b/common/format-output.c @@ -242,7 +239,6 @@ void fmt_print(struct format_ctx *fctx, const char* key, ...) const bool print_colon = row->out_text[0]; int len; - putchar('\n'); fmt_indent1(fctx->indent); len = strlen(row->out_text); @@ -312,6 +308,8 @@ void fmt_print(struct format_ctx *fctx, const char* key, ...) } fmt_end_value(fctx, row); + if (bconf.output_format == CMD_FORMAT_TEXT) + putchar('\n'); /* No newline here, the line is closed by next value or group end */ va_end(args); } Thanks, Sidong ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [RFC] btrfs-progs: format-output: remove newline in fmt_end text mode 2021-02-20 16:42 ` Sidong Yang @ 2021-02-22 15:46 ` David Sterba 0 siblings, 0 replies; 5+ messages in thread From: David Sterba @ 2021-02-22 15:46 UTC (permalink / raw) To: Sidong Yang; +Cc: dsterba, linux-btrfs, Filipe Manana On Sat, Feb 20, 2021 at 04:42:38PM +0000, Sidong Yang wrote: > On Fri, Feb 19, 2021 at 10:56:11PM +0100, David Sterba wrote: > > On Tue, Feb 16, 2021 at 04:28:40PM +0000, Sidong Yang wrote: > > > Remove a code that inserting new line in fmt_end() for text mode. > > > Old code made a failure in fstest btrfs/006. > > > > > > Signed-off-by: Sidong Yang <realwakka@gmail.com> > > > --- > > > Hi, I've just read mail that Filipe written that some failure about fstest. > > > I'm worried about this patch makes other problem. So make it RFC. Thanks. > > > > I found the discussion under the device stats patch adding json, the > > added line was known and "hopefully not causing problems", but the > > fstests seem to notice. > > > > I think we can fix that by removing the fmt_end newline but we also need > > to update how the fmt_print is done for the text output. Ie. for json > > there are some strict rules for line continuations (",") but for the > > textual output, each line ended by "\n" right away, without delaying > > that to the next fmt_* call should work. > > You mean that if this patch applied and the code prints device stats for > text format manually replaced to fmt_print(), there is no last new line > for text output? fmt_print() prints new line before print some value now. > I think that it should prints new line at the end of each fmt_print(). > like below > > diff --git a/common/format-output.c b/common/format-output.c > index f5b12548..9a9f5bf7 100644 > --- a/common/format-output.c > +++ b/common/format-output.c > @@ -242,7 +239,6 @@ void fmt_print(struct format_ctx *fctx, const char* key, ...) > const bool print_colon = row->out_text[0]; > int len; > > - putchar('\n'); > fmt_indent1(fctx->indent); > len = strlen(row->out_text); > > @@ -312,6 +308,8 @@ void fmt_print(struct format_ctx *fctx, const char* key, ...) > } > > fmt_end_value(fctx, row); > + if (bconf.output_format == CMD_FORMAT_TEXT) > + putchar('\n'); Yeah effectively that, but inside fmt_end_value and removing it from fmt_end. It's fixed in devel now with some comments updated as the plain text and json are different. ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-02-22 15:49 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-02-16 16:28 [RFC] btrfs-progs: format-output: remove newline in fmt_end text mode Sidong Yang 2021-02-17 10:57 ` Filipe Manana 2021-02-19 21:56 ` David Sterba 2021-02-20 16:42 ` Sidong Yang 2021-02-22 15:46 ` David Sterba
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.