]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: make unit_can_freeze take const Unit*
authorMike Yuan <me@yhndnzj.com>
Fri, 24 May 2024 14:57:18 +0000 (22:57 +0800)
committerMike Yuan <me@yhndnzj.com>
Wed, 17 Jul 2024 15:25:22 +0000 (17:25 +0200)
src/core/slice.c
src/core/unit.c
src/core/unit.h

index d8c507804f15ae3a563e0e9ae1421b4a19edf99d..12ecd1610da515f6fbabf213b5fb85641853e2f2 100644 (file)
@@ -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;
 }
 
index 01763d75603bb4aa17c89310062e75e056a52346..3a83ed087842f2d0b57e6b5460e019ed1505a887 100644 (file)
@@ -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))
index c961edef5fb3c9e3fc605c04ea26e4b7eca13f47..81502265101017cc87d8841cb4302678e4ebab2f 100644 (file)
@@ -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);