core/service: remove effectively unused NOTIFY_UNKNOWN state

We usually use _INVALID enum value as placeholder.

While at it, reset notify_state in service_enter_dead() for consistency.
This commit is contained in:
Mike Yuan
2025-11-04 12:17:31 +01:00
parent 1b5a9a7d56
commit 38ea58a907
2 changed files with 4 additions and 4 deletions
+4 -3
View File
@@ -185,6 +185,7 @@ static void service_init(Unit *u) {
EXEC_KEYRING_PRIVATE : EXEC_KEYRING_INHERIT;
s->notify_access_override = _NOTIFY_ACCESS_INVALID;
s->notify_state = _NOTIFY_STATE_INVALID;
s->watchdog_original_usec = USEC_INFINITY;
@@ -2177,8 +2178,9 @@ static void service_enter_dead(Service *s, ServiceResult f, bool allow_restart)
/* The next restart might not be a manual stop, hence reset the flag indicating manual stops */
s->forbid_restart = false;
/* Reset NotifyAccess override */
/* Reset notify states */
s->notify_access_override = _NOTIFY_ACCESS_INVALID;
s->notify_state = _NOTIFY_STATE_INVALID;
/* We want fresh tmpdirs and ephemeral snapshots in case the service is started again immediately. */
s->exec_runtime = exec_runtime_destroy(s->exec_runtime);
@@ -2983,7 +2985,7 @@ static int service_start(Unit *u) {
s->status_varlink_error = mfree(s->status_varlink_error);
s->notify_access_override = _NOTIFY_ACCESS_INVALID;
s->notify_state = NOTIFY_UNKNOWN;
s->notify_state = _NOTIFY_STATE_INVALID;
s->watchdog_original_usec = s->watchdog_usec;
s->watchdog_override_enable = false;
@@ -5745,7 +5747,6 @@ static const char* const service_exec_ex_command_table[_SERVICE_EXEC_COMMAND_MAX
DEFINE_STRING_TABLE_LOOKUP(service_exec_ex_command, ServiceExecCommand);
static const char* const notify_state_table[_NOTIFY_STATE_MAX] = {
[NOTIFY_UNKNOWN] = "unknown",
[NOTIFY_READY] = "ready",
[NOTIFY_RELOADING] = "reloading",
[NOTIFY_STOPPING] = "stopping",
-1
View File
@@ -53,7 +53,6 @@ typedef enum ServiceExecCommand {
} ServiceExecCommand;
typedef enum NotifyState {
NOTIFY_UNKNOWN,
NOTIFY_READY,
NOTIFY_RELOADING,
NOTIFY_STOPPING,