From: Zbigniew Jędrzejewski-Szmek Date: Sat, 31 May 2025 13:28:35 +0000 (+0200) Subject: core: do not include names directly in error messages X-Git-Tag: v258-rc1~421^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2b2ca7ff2a46fce6f12cb71c586018060fab09d0;p=thirdparty%2Fsystemd.git core: do not include names directly in error messages This allows some strings constants to be deduplicated. libsystemd-core.so + systemd are about 2k smaller. Also tweak some messages for consistency. We used 'exec' in one place and 'execute' in all other messages. --- diff --git a/src/core/main.c b/src/core/main.c index b1f7cc941bc..330c42482f4 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -1619,7 +1619,7 @@ static void redirect_telinit(int argc, char *argv[]) { return; execv(SYSTEMCTL_BINARY_PATH, argv); - log_error_errno(errno, "Failed to exec " SYSTEMCTL_BINARY_PATH ": %m"); + log_error_errno(errno, "Failed to execute %s: %m", SYSTEMCTL_BINARY_PATH); exit(EXIT_FAILURE); #endif } @@ -2604,12 +2604,12 @@ static int do_queue_default_job( /* Fall back to default.target, which we used to always use by default. Only do this if no * explicit configuration was given. */ - log_info("Falling back to " SPECIAL_DEFAULT_TARGET "."); + log_info("Falling back to %s.", SPECIAL_DEFAULT_TARGET); r = manager_load_startable_unit_or_warn(m, SPECIAL_DEFAULT_TARGET, NULL, &target); } if (r < 0) { - log_info("Falling back to " SPECIAL_RESCUE_TARGET "."); + log_info("Falling back to %s.", SPECIAL_RESCUE_TARGET); r = manager_load_startable_unit_or_warn(m, SPECIAL_RESCUE_TARGET, NULL, &target); if (r < 0) { diff --git a/src/core/mount.c b/src/core/mount.c index 8797dcce180..94105d9db5e 100644 --- a/src/core/mount.c +++ b/src/core/mount.c @@ -2034,10 +2034,9 @@ static void mount_enumerate_perpetual(Manager *m) { u = manager_get_unit(m, SPECIAL_ROOT_MOUNT); if (!u) { r = unit_new_for_name(m, sizeof(Mount), SPECIAL_ROOT_MOUNT, &u); - if (r < 0) { - log_error_errno(r, "Failed to allocate the special " SPECIAL_ROOT_MOUNT " unit: %m"); - return; - } + if (r < 0) + return (void) log_error_errno(r, "Failed to allocate the special %s unit: %m", + SPECIAL_ROOT_MOUNT); } u->perpetual = true; diff --git a/src/core/scope.c b/src/core/scope.c index cf70de573c7..def2039e1a7 100644 --- a/src/core/scope.c +++ b/src/core/scope.c @@ -705,10 +705,9 @@ static void scope_enumerate_perpetual(Manager *m) { u = manager_get_unit(m, SPECIAL_INIT_SCOPE); if (!u) { r = unit_new_for_name(m, sizeof(Scope), SPECIAL_INIT_SCOPE, &u); - if (r < 0) { - log_error_errno(r, "Failed to allocate the special " SPECIAL_INIT_SCOPE " unit: %m"); - return; - } + if (r < 0) + return (void) log_error_errno(r, "Failed to allocate the special %s unit: %m", + SPECIAL_INIT_SCOPE); } u->transient = true; diff --git a/src/core/service.c b/src/core/service.c index c976ee63e4f..295691fd0df 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -819,12 +819,12 @@ static int service_setup_bus_name(Service *s) { if (s->type == SERVICE_DBUS) { r = unit_add_dependency_by_name(UNIT(s), UNIT_REQUIRES, SPECIAL_DBUS_SOCKET, true, UNIT_DEPENDENCY_FILE); if (r < 0) - return log_unit_error_errno(UNIT(s), r, "Failed to add dependency on " SPECIAL_DBUS_SOCKET ": %m"); + return log_unit_error_errno(UNIT(s), r, "Failed to add dependency on %s: %m", SPECIAL_DBUS_SOCKET); /* We always want to be ordered against dbus.socket if both are in the transaction. */ r = unit_add_dependency_by_name(UNIT(s), UNIT_AFTER, SPECIAL_DBUS_SOCKET, true, UNIT_DEPENDENCY_FILE); if (r < 0) - return log_unit_error_errno(UNIT(s), r, "Failed to add dependency on " SPECIAL_DBUS_SOCKET ": %m"); + return log_unit_error_errno(UNIT(s), r, "Failed to add dependency on %s: %m", SPECIAL_DBUS_SOCKET); } r = unit_watch_bus_name(UNIT(s), s->bus_name);