From 6320a4e9534595d9c5f0d6d73e6858f548092a3e Mon Sep 17 00:00:00 2001 From: Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> Date: Wed, 19 Feb 2025 11:50:08 +0100 Subject: Fix one-line formatting --- lib/output.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/output.c b/lib/output.c index 2c40bc7f..62a00fed 100644 --- a/lib/output.c +++ b/lib/output.c @@ -260,7 +260,7 @@ char *mp_fmt_output(mp_check check) { subchecks = subchecks->next; } - break; + return result; } case MP_FORMAT_ICINGA_WEB_2: { if (check.summary == NULL) { @@ -354,13 +354,14 @@ static char *generate_indentation_string(unsigned int indentation) { */ static inline char *fmt_subcheck_output(mp_output_format output_format, mp_subcheck check, unsigned int indentation) { char *result = NULL; + mp_subcheck_list *subchecks = NULL; switch (output_format) { case MP_FORMAT_ICINGA_WEB_2: xasprintf(&result, "%s\\_[%s] - %s", generate_indentation_string(indentation), state_text(mp_compute_subcheck_state(check)), check.output); - mp_subcheck_list *subchecks = check.subchecks; + subchecks = check.subchecks; while (subchecks != NULL) { xasprintf(&result, "%s\n%s", result, fmt_subcheck_output(output_format, subchecks->subcheck, indentation + 1)); @@ -368,6 +369,14 @@ static inline char *fmt_subcheck_output(mp_output_format output_format, mp_subch } return result; case MP_FORMAT_ONE_LINE: + xasprintf(&result, "[%s] - %s", state_text(mp_compute_subcheck_state(check)), check.output); + + subchecks = check.subchecks; + + while (subchecks != NULL) { + xasprintf(&result, " - %s\n%s", result, fmt_subcheck_output(output_format, subchecks->subcheck, indentation + 1)); + subchecks = subchecks->next; + } return result; case MP_FORMAT_SUMMARY_ONLY: return result; -- cgit v1.2.3-74-g34f1