anitazha / rpms / systemd

Forked from rpms/systemd 3 years ago
Clone

Blame SOURCES/0237-bus-util-print-correct-warnings-for-units-that-fail-.patch

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