]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/core/scope.c
core: introduce a helper function to wrap unit_log_{success,failure}
[thirdparty/systemd.git] / src / core / scope.c
index 40503a59611c1b4e127dbf27b1f9b7a785330792..151b8989a6416bb38bd7aada60a2ffdb6874636c 100644 (file)
@@ -8,6 +8,7 @@
 #include "load-dropin.h"
 #include "log.h"
 #include "scope.h"
+#include "serialize.h"
 #include "special.h"
 #include "string-table.h"
 #include "string-util.h"
@@ -239,9 +240,7 @@ static void scope_enter_dead(Scope *s, ScopeResult f) {
         if (s->result == SCOPE_SUCCESS)
                 s->result = f;
 
-        if (s->result != SCOPE_SUCCESS)
-                log_unit_warning(UNIT(s), "Failed with result '%s'.", scope_result_to_string(s->result));
-
+        unit_log_result(UNIT(s), s->result == SCOPE_SUCCESS, scope_result_to_string(s->result));
         scope_set_state(s, s->result != SCOPE_SUCCESS ? SCOPE_FAILED : SCOPE_DEAD);
 }
 
@@ -402,11 +401,11 @@ static int scope_serialize(Unit *u, FILE *f, FDSet *fds) {
         assert(f);
         assert(fds);
 
-        unit_serialize_item(u, f, "state", scope_state_to_string(s->state));
-        unit_serialize_item(u, f, "was-abandoned", yes_no(s->was_abandoned));
+        (void) serialize_item(f, "state", scope_state_to_string(s->state));
+        (void) serialize_bool(f, "was-abandoned", s->was_abandoned);
 
         if (s->controller)
-                unit_serialize_item(u, f, "controller", s->controller);
+                (void) serialize_item(f, "controller", s->controller);
 
         return 0;
 }
@@ -441,7 +440,7 @@ static int scope_deserialize_item(Unit *u, const char *key, const char *value, F
 
                 r = free_and_strdup(&s->controller, value);
                 if (r < 0)
-                        log_oom();
+                        return log_oom();
 
         } else
                 log_unit_debug(u, "Unknown serialization key: %s", key);