From b21bebbe70313646ef16a7d812f8d8e092f77d99 Mon Sep 17 00:00:00 2001 From: Mike Yuan Date: Fri, 24 May 2024 22:57:18 +0800 Subject: [PATCH] core: make unit_can_freeze take const Unit* --- src/core/slice.c | 10 +++++----- src/core/unit.c | 2 +- src/core/unit.h | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/core/slice.c b/src/core/slice.c index d8c507804f1..12ecd1610da 100644 --- a/src/core/slice.c +++ b/src/core/slice.c @@ -339,14 +339,14 @@ static void slice_enumerate_perpetual(Manager *m) { (void) slice_make_perpetual(m, SPECIAL_SYSTEM_SLICE, NULL); } -static bool slice_can_freeze(Unit *s) { - Unit *member; - - assert(s); +static bool slice_can_freeze(const Unit *u) { + assert(u); - UNIT_FOREACH_DEPENDENCY(member, s, UNIT_ATOM_SLICE_OF) + Unit *member; + UNIT_FOREACH_DEPENDENCY(member, u, UNIT_ATOM_SLICE_OF) if (!unit_can_freeze(member)) return false; + return true; } diff --git a/src/core/unit.c b/src/core/unit.c index 01763d75603..3a83ed08784 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -6228,7 +6228,7 @@ void unit_next_freezer_state(Unit *u, FreezerAction action, FreezerState *ret, F *ret_target = tgt; } -bool unit_can_freeze(Unit *u) { +bool unit_can_freeze(const Unit *u) { assert(u); if (unit_has_name(u, SPECIAL_ROOT_SLICE) || unit_has_name(u, SPECIAL_INIT_SCOPE)) diff --git a/src/core/unit.h b/src/core/unit.h index c961edef5fb..81502265101 100644 --- a/src/core/unit.h +++ b/src/core/unit.h @@ -577,7 +577,7 @@ typedef struct UnitVTable { /* Freeze or thaw the unit. Returns > 0 to indicate that the request will be handled asynchronously; unit_frozen * or unit_thawed should be called once the operation is done. Returns 0 if done successfully, or < 0 on error. */ int (*freezer_action)(Unit *u, FreezerAction a); - bool (*can_freeze)(Unit *u); + bool (*can_freeze)(const Unit *u); /* Return which kind of data can be cleaned */ int (*can_clean)(Unit *u, ExecCleanMask *ret); @@ -1036,7 +1036,7 @@ bool unit_can_start_refuse_manual(Unit *u); bool unit_can_stop_refuse_manual(Unit *u); bool unit_can_isolate_refuse_manual(Unit *u); -bool unit_can_freeze(Unit *u); +bool unit_can_freeze(const Unit *u); int unit_freezer_action(Unit *u, FreezerAction action); void unit_next_freezer_state(Unit *u, FreezerAction a, FreezerState *ret, FreezerState *ret_tgt); void unit_frozen(Unit *u); -- 2.47.3