From 6efb21c218d4ec38c1a4d7dbb86f2028f122acaa Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Tue, 9 Feb 2016 13:19:34 -0700 Subject: [PATCH] diskutil: fix segfault for both json and terse output Signed-off-by: Jens Axboe --- diskutil.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/diskutil.c b/diskutil.c index c3181b5b..074f1307 100644 --- a/diskutil.c +++ b/diskutil.c @@ -695,6 +695,7 @@ void show_disk_util(int terse, struct json_object *parent, { struct flist_head *entry; struct disk_util *du; + bool do_json; if (!disk_util_mutex) return; @@ -706,13 +707,15 @@ void show_disk_util(int terse, struct json_object *parent, return; } - if (output_format & FIO_OUTPUT_JSON) - assert(parent); + if ((output_format & FIO_OUTPUT_JSON) && parent) + do_json = true; + else + do_json = false; - if (!terse && !(output_format & FIO_OUTPUT_JSON)) + if (!terse && !do_json) log_buf(out, "\nDisk stats (read/write):\n"); - if (output_format & FIO_OUTPUT_JSON) + if (do_json) json_object_add_disk_utils(parent, &disk_list); if (output_format & ~(FIO_OUTPUT_JSON | FIO_OUTPUT_JSON_PLUS)) { flist_for_each(entry, &disk_list) { -- 2.25.1