]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: do not include names directly in error messages
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 31 May 2025 13:28:35 +0000 (15:28 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 31 May 2025 13:35:02 +0000 (15:35 +0200)
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.

src/core/main.c
src/core/mount.c
src/core/scope.c
src/core/service.c

index b1f7cc941bc05e2f8c4e399eb565bed7012744a9..330c42482f42fb40bddb2c82a11214211a97b618 100644 (file)
@@ -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) {
index 8797dcce180b6a6e7f06af9b047e77a21f8152fe..94105d9db5e58005c5e084f9c72e63b7cf943eb8 100644 (file)
@@ -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;
index cf70de573c76285a6c98131151d17b1f25ea7fcf..def2039e1a7cf8f6557e9eb361a476881ee254c8 100644 (file)
@@ -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;
index c976ee63e4f2c98f6cd42c9d3f0f84b7b9ddfbe0..295691fd0df3b7c65a9563a5d37ec0d41e852059 100644 (file)
@@ -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);