Module: monitoring-plugins
 Branch: master
 Commit: 6320a4e9534595d9c5f0d6d73e6858f548092a3e
 Author: Lorenz Kästle <12514511+rincewinds...@users.noreply.github.com>
   Date: Wed Feb 19 11:50:08 2025 +0100
    URL: 
https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=6320a4e9

Fix one-line formatting

---

 lib/output.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

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;

Reply via email to