From 38ea58a907a84573d6064b72613e4ed0124162a4 Mon Sep 17 00:00:00 2001 From: Mike Yuan Date: Sun, 19 Oct 2025 21:47:54 +0200 Subject: [PATCH] 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. --- src/core/service.c | 7 ++++--- src/core/service.h | 1 - 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/service.c b/src/core/service.c index 49c4b52af18..a8c6883294e 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -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", diff --git a/src/core/service.h b/src/core/service.h index 8965dc827b6..e27b382e802 100644 --- a/src/core/service.h +++ b/src/core/service.h @@ -53,7 +53,6 @@ typedef enum ServiceExecCommand { } ServiceExecCommand; typedef enum NotifyState { - NOTIFY_UNKNOWN, NOTIFY_READY, NOTIFY_RELOADING, NOTIFY_STOPPING, -- 2.47.3