summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-11-16 10:09:45 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-11-16 19:47:07 +0100
commitaac99f303af42fa8702abc129d0525f3e6903423 (patch)
tree9dc64ec40b844025c9f3fc3882e594128b01cb22 /src/core
parentMerge pull request #10805 from poettering/migrate-boot-loader-interface (diff)
downloadsystemd-aac99f303af42fa8702abc129d0525f3e6903423.tar.xz
systemd-aac99f303af42fa8702abc129d0525f3e6903423.zip
core: introduce a helper function to wrap unit_log_{success,failure}
It's inline so that the compiler can easily optimize away the call to get status string.
Diffstat (limited to 'src/core')
-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
8 files changed, 14 insertions, 34 deletions
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 */