From: Daan De Meyer Date: Wed, 3 Aug 2022 13:39:12 +0000 (+0200) Subject: repart: Remove unnecessary newlines from JSON output X-Git-Tag: v252-rc1~527 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=06c5a3847be9a86dfc60c2872068eec8acbc89d5;p=thirdparty%2Fsystemd.git repart: Remove unnecessary newlines from JSON output Before ``` ➜ systemd git:(dissect-have-blkid) SYSTEMD_LOG_LEVEL=err build/systemd-repart --definitions definitions/ --dry-run=yes --empty=create --size=100M --json=pretty abc [ { "type" : "root-x86-64", "label" : "root-x86-64", "uuid" : "2f7c902c-6b2a-4b47-a44b-dca765f38cd2", "file" : "root.conf", "node" : "abc1", "offset" : 1048576, "old_size" : 0, "raw_size" : 103788544, "old_padding" : 0, "raw_padding" : 0, "activity" : "create" } ] ➜ systemd git:(dissect-have-blkid) ``` After: ``` ➜ systemd git:(repart-newlines) SYSTEMD_LOG_LEVEL=err build/systemd-repart --definitions definitions/ --dry-run=yes --empty=create --size=100M --json=pretty abc [ { "type" : "root-x86-64", "label" : "root-x86-64", "uuid" : "2f7c902c-6b2a-4b47-a44b-dca765f38cd2", "file" : "root.conf", "node" : "abc1", "offset" : 1048576, "old_size" : 0, "raw_size" : 103788544, "old_padding" : 0, "raw_padding" : 0, "activity" : "create" } ] ➜ systemd git:(repart-newlines) ``` --- diff --git a/src/partition/repart.c b/src/partition/repart.c index 893431da2a9..f377908a338 100644 --- a/src/partition/repart.c +++ b/src/partition/repart.c @@ -3460,11 +3460,12 @@ static int context_write_partition_table( (void) context_dump_partitions(context, node); - putc('\n', stdout); - - if (arg_json_format_flags & JSON_FORMAT_OFF) + if (arg_json_format_flags & JSON_FORMAT_OFF) { + putc('\n', stdout); (void) context_dump_partition_bar(context, node); - putc('\n', stdout); + putc('\n', stdout); + } + fflush(stdout); }