ryantimwilson / rpms / systemd

Forked from rpms/systemd a month ago
Clone
1ff636
From caff38650c2c1ae9244a30b87275db3d3a5e3b5d Mon Sep 17 00:00:00 2001
1ff636
From: Lennart Poettering <lennart@poettering.net>
1ff636
Date: Tue, 28 Apr 2015 12:12:29 +0200
1ff636
Subject: [PATCH] bus-util: print correct warnings for units that fail but for
1ff636
 which we have a NULL result only
1ff636
1ff636
Cherry-picked from: 373a99e
1ff636
Related: #1016680
1ff636
---
23b3cf
 src/libsystemd/sd-bus/bus-util.c | 34 +++++++++++++++++++-------------
1ff636
 1 file changed, 20 insertions(+), 14 deletions(-)
1ff636
1ff636
diff --git a/src/libsystemd/sd-bus/bus-util.c b/src/libsystemd/sd-bus/bus-util.c
c62b8e
index 017fbaf2a3..e48abf55a3 100644
1ff636
--- a/src/libsystemd/sd-bus/bus-util.c
1ff636
+++ b/src/libsystemd/sd-bus/bus-util.c
1ff636
@@ -1724,28 +1724,34 @@ static const struct {
1ff636
 };
1ff636
 
1ff636
 static void log_job_error_with_service_result(const char* service, const char *result) {
1ff636
-        unsigned i;
1ff636
         _cleanup_free_ char *service_shell_quoted = NULL;
1ff636
 
1ff636
         assert(service);
1ff636
-        assert(result);
1ff636
 
1ff636
         service_shell_quoted = shell_maybe_quote(service);
1ff636
 
1ff636
-        for (i = 0; i < ELEMENTSOF(explanations); ++i)
1ff636
-                if (streq(result, explanations[i].result))
1ff636
-                        break;
1ff636
+        if (!isempty(result)) {
1ff636
+                unsigned i;
1ff636
 
1ff636
-        if (i < ELEMENTSOF(explanations))
1ff636
-                log_error("Job for %s failed because %s. See \"systemctl status %s\" and \"journalctl -xe\" for details.\n",
1ff636
-                          service,
1ff636
-                          explanations[i].explanation,
1ff636
-                          strna(service_shell_quoted));
1ff636
-        else
1ff636
-                log_error("Job for %s failed. See \"systemctl status %s\" and \"journalctl -xe\" for details.\n",
1ff636
-                          service,
1ff636
-                          strna(service_shell_quoted));
1ff636
+                for (i = 0; i < ELEMENTSOF(explanations); ++i)
1ff636
+                        if (streq(result, explanations[i].result))
1ff636
+                                break;
1ff636
+
1ff636
+                if (i < ELEMENTSOF(explanations)) {
1ff636
+                        log_error("Job for %s failed because %s. See \"systemctl status %s\" and \"journalctl -xe\" for details.\n",
1ff636
+                                  service,
1ff636
+                                  explanations[i].explanation,
1ff636
+                                  strna(service_shell_quoted));
1ff636
 
1ff636
+                        goto finish;
1ff636
+                }
1ff636
+        }
1ff636
+
1ff636
+        log_error("Job for %s failed. See \"systemctl status %s\" and \"journalctl -xe\" for details.\n",
1ff636
+                  service,
1ff636
+                  strna(service_shell_quoted));
1ff636
+
1ff636
+finish:
1ff636
         /* For some results maybe additional explanation is required */
1ff636
         if (streq_ptr(result, "start-limit"))
1ff636
                 log_info("To force a start use \"systemctl reset-failed %1$s\" followed by \"systemctl start %1$s\" again.",