]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core,unit-def: use our usual way of asserting enums
authorMike Yuan <me@yhndnzj.com>
Fri, 24 May 2024 14:52:28 +0000 (22:52 +0800)
committerMike Yuan <me@yhndnzj.com>
Wed, 17 Jul 2024 15:25:22 +0000 (17:25 +0200)
src/basic/unit-def.c
src/core/cgroup.c
src/core/cgroup.h
src/core/slice.c
src/core/unit.c

index 6ffdcd37c8c14265de3aa14210558c93d63a1b3d..4dc8ceef865f6ae08c6ec402819b7e23858aa12a 100644 (file)
@@ -140,7 +140,9 @@ static const FreezerState freezer_state_finish_table[_FREEZER_STATE_MAX] = {
 };
 
 FreezerState freezer_state_finish(FreezerState state) {
-        assert(state >= 0 && state < _FREEZER_STATE_MAX);
+        assert(state >= 0);
+        assert(state < _FREEZER_STATE_MAX);
+
         return freezer_state_finish_table[state];
 }
 
index 9620436f6873141898bba78278c11f288b23c67d..218f867f24739b8f3ae01e7503d1890d91e5df4e 100644 (file)
@@ -5110,8 +5110,8 @@ int unit_cgroup_freezer_action(Unit *u, FreezerAction action) {
         int r;
 
         assert(u);
-        assert(IN_SET(action, FREEZER_FREEZE, FREEZER_PARENT_FREEZE,
-                              FREEZER_THAW, FREEZER_PARENT_THAW));
+        assert(action >= 0);
+        assert(action < _FREEZER_ACTION_MAX);
 
         if (!cg_freezer_supported())
                 return 0;
index e31e69364e2ef32ae14b20323288d9b5e9d38eb9..1c5c1f75abd4b9a652b63224084416285dee292c 100644 (file)
@@ -60,7 +60,6 @@ typedef enum FreezerAction {
         FREEZER_PARENT_FREEZE,
         FREEZER_THAW,
         FREEZER_PARENT_THAW,
-
         _FREEZER_ACTION_MAX,
         _FREEZER_ACTION_INVALID = -EINVAL,
 } FreezerAction;
@@ -514,6 +513,7 @@ void unit_cgroup_catchup(Unit *u);
 bool unit_cgroup_delegate(Unit *u);
 
 int unit_get_cpuset(Unit *u, CPUSet *cpus, const char *name);
+
 int unit_cgroup_freezer_action(Unit *u, FreezerAction action);
 
 const char* freezer_action_to_string(FreezerAction a) _const_;
index 4e71976e4fc8adebf4bdc4a160d3799c470c0318..d8c507804f15ae3a563e0e9ae1421b4a19edf99d 100644 (file)
@@ -356,8 +356,8 @@ static int slice_freezer_action(Unit *s, FreezerAction action) {
         int r;
 
         assert(s);
-        assert(IN_SET(action, FREEZER_FREEZE, FREEZER_PARENT_FREEZE,
-                      FREEZER_THAW, FREEZER_PARENT_THAW));
+        assert(action >= 0);
+        assert(action < _FREEZER_ACTION_MAX);
 
         if (action == FREEZER_FREEZE && !slice_can_freeze(s)) {
                 /* We're intentionally only checking for FREEZER_FREEZE here and ignoring the
index 8cdb3a025f8dc3fa953437f903ce01f4c9ceda72..01763d75603bb4aa17c89310062e75e056a52346 100644 (file)
@@ -6161,8 +6161,8 @@ void unit_next_freezer_state(Unit *u, FreezerAction action, FreezerState *ret, F
         FreezerState curr, parent, next, tgt;
 
         assert(u);
-        assert(IN_SET(action, FREEZER_FREEZE, FREEZER_PARENT_FREEZE,
-                              FREEZER_THAW, FREEZER_PARENT_THAW));
+        assert(action >= 0);
+        assert(action < _FREEZER_ACTION_MAX);
         assert(ret);
         assert(ret_target);