From f4d4447ce2347def82f9dbfc90d08a5fbbd8b22f Mon Sep 17 00:00:00 2001 From: Sebastien GODARD Date: Sat, 27 Apr 2019 09:31:19 +0200 Subject: [PATCH] Fix #222: Invalid JSON output displayed by iostat Commit 5adec60 introduced a regression: JSON output was no longer valid when option -y was used with iostat. Signed-off-by: Sebastien GODARD --- iostat.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/iostat.c b/iostat.c index 4e3d5a3..d93a0b5 100644 --- a/iostat.c +++ b/iostat.c @@ -1918,9 +1918,6 @@ void rw_io_stat_loop(long int count, struct tm *rectime, int iodev_nr, int dlist count--; } } - else { - skip = 0; - } if (count) { curr ^= 1; @@ -1930,9 +1927,10 @@ void rw_io_stat_loop(long int count, struct tm *rectime, int iodev_nr, int dlist /* SIGINT signal caught => Terminate JSON output properly */ count = 0; } - else if (DISPLAY_JSON_OUTPUT(flags) && count) { + else if (DISPLAY_JSON_OUTPUT(flags) && count && !skip) { printf(","); } + skip = 0; } printf("\n"); } -- 2.40.0