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 <sysstat@users.noreply.github.com>
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++) {
printf("\n");
xprintf0(--tab, "]");
+
+ tab --;
+
+close_json_markup:
+ if (CLOSE_MARKUP(a->options)) {
+ json_markup_network(tab, CLOSE_JSON_MARKUP);
+ }
}