From 54b03d154d46cbb94d2f29c2f85cafb69962660e Mon Sep 17 00:00:00 2001 From: Sebastien GODARD Date: Tue, 26 Jan 2016 22:43:23 +0100 Subject: [PATCH] JSON: Don't display fchosts tag when no stats exist The JSON print function can be called for A_NET_FC (Fibre Channel) activity even if no statistics exist. This is because this activity has the AO_CLOSE_MARKUP flag used to close the "network" section of the output. Anyway, in this case (when no stats exist), it should only do that (close the network section) et not display the "fchost" tag. Signed-off-by: Sebastien GODARD --- json_stats.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/json_stats.c b/json_stats.c index 8e6ec84..7e38a3c 100644 --- a/json_stats.c +++ b/json_stats.c @@ -2178,6 +2178,12 @@ __print_funct_t json_print_fchost_stats(struct activity *a, int curr, int tab, struct stats_fchost *sfcc, *sfcp; int sep = FALSE; + if (!IS_SELECTED(a->options) || (a->nr <= 0)) + goto close_json_markup; + + json_markup_network(tab, OPEN_JSON_MARKUP); + tab++; + xprintf(tab++, "\"fchosts\": ["); for (i = 0; i < a->nr; i++) { @@ -2207,4 +2213,11 @@ __print_funct_t json_print_fchost_stats(struct activity *a, int curr, int tab, printf("\n"); xprintf0(--tab, "]"); + + tab --; + +close_json_markup: + if (CLOSE_MARKUP(a->options)) { + json_markup_network(tab, CLOSE_JSON_MARKUP); + } } -- 2.49.0