summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-11-19 11:07:07 +0100
committerGitHub <noreply@github.com>2018-11-19 11:07:07 +0100
commitb08020893af11b9f5fd99b6e6fe1755d4fbcd811 (patch)
treeb23f98a723c7133b80c6b897ced14185e0d9bba1
parentMerge pull request #10814 from poettering/logind-suspend-fallback (diff)
parentTODO: add entry (diff)
downloadsystemd-b08020893af11b9f5fd99b6e6fe1755d4fbcd811.tar.xz
systemd-b08020893af11b9f5fd99b6e6fe1755d4fbcd811.zip
Merge pull request #10809 from keszybz/unit-log-result
Add helper function for logging unit results
-rw-r--r--TODO2
-rw-r--r--src/core/automount.c6
-rw-r--r--src/core/mount.c6
-rw-r--r--src/core/path.c6
-rw-r--r--src/core/scope.c6
-rw-r--r--src/core/service.c5
-rw-r--r--src/core/swap.c6
-rw-r--r--src/core/timer.c6
-rw-r--r--src/core/unit.h7
9 files changed, 16 insertions, 34 deletions
diff --git a/TODO b/TODO
index dbd5b10839..29ccde88a2 100644
--- a/TODO
+++ b/TODO
@@ -6,6 +6,8 @@ Bugfixes:
manager or system manager can be always set. It would be better to reject
them when parsing config.
+* Clarify what IPAddress* matches (source, destination, both?)
+
External:
* Fedora: add an rpmlint check that verifies that all unit files in the RPM are listed in %systemd_post macros.
diff --git a/src/core/automount.c b/src/core/automount.c
index 9da3f87fca..5c1748542e 100644
--- a/src/core/automount.c
+++ b/src/core/automount.c
@@ -315,11 +315,7 @@ static void automount_enter_dead(Automount *a, AutomountResult f) {
if (a->result == AUTOMOUNT_SUCCESS)
a->result = f;
- if (a->result == AUTOMOUNT_SUCCESS)
- unit_log_success(UNIT(a));
- else
- unit_log_failure(UNIT(a), automount_result_to_string(a->result));
-
+ unit_log_result(UNIT(a), a->result == AUTOMOUNT_SUCCESS, automount_result_to_string(a->result));
automount_set_state(a, a->result != AUTOMOUNT_SUCCESS ? AUTOMOUNT_FAILED : AUTOMOUNT_DEAD);
}
diff --git a/src/core/mount.c b/src/core/mount.c
index 8035a73184..8c19150112 100644
--- a/src/core/mount.c
+++ b/src/core/mount.c
@@ -799,11 +799,7 @@ static void mount_enter_dead(Mount *m, MountResult f) {
if (m->result == MOUNT_SUCCESS)
m->result = f;
- if (m->result == MOUNT_SUCCESS)
- unit_log_success(UNIT(m));
- else
- unit_log_failure(UNIT(m), mount_result_to_string(m->result));
-
+ unit_log_result(UNIT(m), m->result == MOUNT_SUCCESS, mount_result_to_string(m->result));
mount_set_state(m, m->result != MOUNT_SUCCESS ? MOUNT_FAILED : MOUNT_DEAD);
m->exec_runtime = exec_runtime_unref(m->exec_runtime, true);
diff --git a/src/core/path.c b/src/core/path.c
index 7523bf54f7..e649cc232e 100644
--- a/src/core/path.c
+++ b/src/core/path.c
@@ -449,11 +449,7 @@ static void path_enter_dead(Path *p, PathResult f) {
if (p->result == PATH_SUCCESS)
p->result = f;
- if (p->result == PATH_SUCCESS)
- unit_log_success(UNIT(p));
- else
- unit_log_failure(UNIT(p), path_result_to_string(p->result));
-
+ unit_log_result(UNIT(p), p->result == PATH_SUCCESS, path_result_to_string(p->result));
path_set_state(p, p->result != PATH_SUCCESS ? PATH_FAILED : PATH_DEAD);
}
diff --git a/src/core/scope.c b/src/core/scope.c
index 6d8d4af56d..151b8989a6 100644
--- a/src/core/scope.c
+++ b/src/core/scope.c
@@ -240,11 +240,7 @@ static void scope_enter_dead(Scope *s, ScopeResult f) {
if (s->result == SCOPE_SUCCESS)
s->result = f;
- if (s->result == SCOPE_SUCCESS)
- unit_log_success(UNIT(s));
- else
- unit_log_failure(UNIT(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);
}
diff --git a/src/core/service.c b/src/core/service.c
index a90711213c..7675663f8b 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -1699,10 +1699,7 @@ static void service_enter_dead(Service *s, ServiceResult f, bool allow_restart)
if (s->result == SERVICE_SUCCESS)
s->result = f;
- if (s->result == SERVICE_SUCCESS)
- unit_log_success(UNIT(s));
- else
- unit_log_failure(UNIT(s), service_result_to_string(s->result));
+ unit_log_result(UNIT(s), s->result == SERVICE_SUCCESS, service_result_to_string(s->result));
if (allow_restart && service_shall_restart(s))
s->will_auto_restart = true;
diff --git a/src/core/swap.c b/src/core/swap.c
index e2b888ec9e..6a2e13f56e 100644
--- a/src/core/swap.c
+++ b/src/core/swap.c
@@ -653,11 +653,7 @@ static void swap_enter_dead(Swap *s, SwapResult f) {
if (s->result == SWAP_SUCCESS)
s->result = f;
- if (s->result == SWAP_SUCCESS)
- unit_log_success(UNIT(s));
- else
- unit_log_failure(UNIT(s), swap_result_to_string(s->result));
-
+ unit_log_result(UNIT(s), s->result == SWAP_SUCCESS, swap_result_to_string(s->result));
swap_set_state(s, s->result != SWAP_SUCCESS ? SWAP_FAILED : SWAP_DEAD);
s->exec_runtime = exec_runtime_unref(s->exec_runtime, true);
diff --git a/src/core/timer.c b/src/core/timer.c
index c7f769dbe1..4e7fade999 100644
--- a/src/core/timer.c
+++ b/src/core/timer.c
@@ -288,11 +288,7 @@ static void timer_enter_dead(Timer *t, TimerResult f) {
if (t->result == TIMER_SUCCESS)
t->result = f;
- if (t->result == TIMER_SUCCESS)
- unit_log_success(UNIT(t));
- else
- unit_log_failure(UNIT(t), timer_result_to_string(t->result));
-
+ unit_log_result(UNIT(t), t->result == TIMER_SUCCESS, timer_result_to_string(t->result));
timer_set_state(t, t->result != TIMER_SUCCESS ? TIMER_FAILED : TIMER_DEAD);
}
diff --git a/src/core/unit.h b/src/core/unit.h
index 3931684a56..f159233df9 100644
--- a/src/core/unit.h
+++ b/src/core/unit.h
@@ -808,6 +808,13 @@ int unit_pid_attachable(Unit *unit, pid_t pid, sd_bus_error *error);
void unit_log_success(Unit *u);
void unit_log_failure(Unit *u, const char *result);
+static inline void unit_log_result(Unit *u, bool success, const char *result) {
+ if (success)
+ unit_log_success(u);
+ else
+ unit_log_failure(u, result);
+}
+
void unit_log_process_exit(Unit *u, int level, const char *kind, const char *command, int code, int status);
/* Macros which append UNIT= or USER_UNIT= to the message */