core,unit-def: use our usual way of asserting enums

This commit is contained in:
Mike Yuan
2024-07-17 17:25:22 +02:00
parent e2f81f8d40
commit 21fed6eaec
5 changed files with 10 additions and 8 deletions
+3 -1
View 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];
}
+2 -2
View 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;
+1 -1
View 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_;
+2 -2
View 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
+2 -2
View 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);