From b7e4e152cf21c11ad0fd093d698520b2fa6fb1fb Mon Sep 17 00:00:00 2001 From: Mike Yuan Date: Sat, 6 Apr 2024 22:04:17 +0800 Subject: [PATCH] core: use log_unit_debug in *_set_state --- src/core/scope.c | 3 ++- src/core/slice.c | 20 +++++++++----------- src/core/target.c | 7 +++---- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/core/scope.c b/src/core/scope.c index 08319ac8f4a..14d6c1f6a46 100644 --- a/src/core/scope.c +++ b/src/core/scope.c @@ -99,7 +99,8 @@ static void scope_set_state(Scope *s, ScopeState state) { } if (state != old_state) - log_debug("%s changed %s -> %s", UNIT(s)->id, scope_state_to_string(old_state), scope_state_to_string(state)); + log_unit_debug(UNIT(s), "Changed %s -> %s", + scope_state_to_string(old_state), scope_state_to_string(state)); unit_notify(UNIT(s), state_translation_table[old_state], state_translation_table[state], /* reload_success = */ true); } diff --git a/src/core/slice.c b/src/core/slice.c index a99c0d70b33..4e71976e4fc 100644 --- a/src/core/slice.c +++ b/src/core/slice.c @@ -27,24 +27,22 @@ static void slice_init(Unit *u) { u->ignore_on_isolate = true; } -static void slice_set_state(Slice *t, SliceState state) { +static void slice_set_state(Slice *s, SliceState state) { SliceState old_state; - assert(t); + assert(s); - if (t->state != state) - bus_unit_send_pending_change_signal(UNIT(t), false); + if (s->state != state) + bus_unit_send_pending_change_signal(UNIT(s), false); - old_state = t->state; - t->state = state; + old_state = s->state; + s->state = state; if (state != old_state) - log_debug("%s changed %s -> %s", - UNIT(t)->id, - slice_state_to_string(old_state), - slice_state_to_string(state)); + log_unit_debug(UNIT(s), "Changed %s -> %s", + slice_state_to_string(old_state), slice_state_to_string(state)); - unit_notify(UNIT(t), state_translation_table[old_state], state_translation_table[state], /* reload_success = */ true); + unit_notify(UNIT(s), state_translation_table[old_state], state_translation_table[state], /* reload_success = */ true); } static int slice_add_parent_slice(Slice *s) { diff --git a/src/core/target.c b/src/core/target.c index 3351b1fc2bb..d9362b8b164 100644 --- a/src/core/target.c +++ b/src/core/target.c @@ -17,6 +17,7 @@ static const UnitActiveState state_translation_table[_TARGET_STATE_MAX] = { static void target_set_state(Target *t, TargetState state) { TargetState old_state; + assert(t); if (t->state != state) @@ -26,10 +27,8 @@ static void target_set_state(Target *t, TargetState state) { t->state = state; if (state != old_state) - log_debug("%s changed %s -> %s", - UNIT(t)->id, - target_state_to_string(old_state), - target_state_to_string(state)); + log_unit_debug(UNIT(t), "Changed %s -> %s", + target_state_to_string(old_state), target_state_to_string(state)); unit_notify(UNIT(t), state_translation_table[old_state], state_translation_table[state], /* reload_success = */ true); } -- 2.47.3