From: Jens Axboe Date: Tue, 9 Feb 2016 20:19:34 +0000 (-0700) Subject: diskutil: fix segfault for both json and terse output X-Git-Tag: fio-2.7~24 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=6efb21c218d4ec38c1a4d7dbb86f2028f122acaa;ds=inline diskutil: fix segfault for both json and terse output Signed-off-by: Jens Axboe --- 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) {