dryang / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
8d419f
From 0d19f19be9a93642f10b4c039aafd9e62f35e8fc Mon Sep 17 00:00:00 2001
8d419f
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
8d419f
Date: Thu, 17 Mar 2022 10:16:30 +0100
8d419f
Subject: [PATCH] shared/install: stop passing duplicate root argument to
8d419f
 install_name_printf()
8d419f
8d419f
All callers were just passing info + info->root, we can simplify this.
8d419f
8d419f
(cherry picked from commit 38e8a6c7fdffd3389cb3596139b1309579193946)
8d419f
8d419f
Related: #2082131
8d419f
---
8d419f
 src/shared/install-printf.c   | 7 +++----
8d419f
 src/shared/install-printf.h   | 3 +--
8d419f
 src/shared/install.c          | 8 ++++----
8d419f
 src/test/test-load-fragment.c | 2 +-
8d419f
 4 files changed, 9 insertions(+), 11 deletions(-)
8d419f
8d419f
diff --git a/src/shared/install-printf.c b/src/shared/install-printf.c
8d419f
index 963102674b..7aad1b7443 100644
8d419f
--- a/src/shared/install-printf.c
8d419f
+++ b/src/shared/install-printf.c
8d419f
@@ -105,9 +105,8 @@ static int specifier_last_component(char specifier, const void *data, const char
8d419f
 
8d419f
 int install_name_printf(
8d419f
                 UnitFileScope scope,
8d419f
-                const UnitFileInstallInfo *i,
8d419f
+                const UnitFileInstallInfo *info,
8d419f
                 const char *format,
8d419f
-                const char *root,
8d419f
                 char **ret) {
8d419f
         /* This is similar to unit_name_printf() */
8d419f
 
8d419f
@@ -124,9 +123,9 @@ int install_name_printf(
8d419f
                 {}
8d419f
         };
8d419f
 
8d419f
-        assert(i);
8d419f
+        assert(info);
8d419f
         assert(format);
8d419f
         assert(ret);
8d419f
 
8d419f
-        return specifier_printf(format, UNIT_NAME_MAX, table, root, i, ret);
8d419f
+        return specifier_printf(format, UNIT_NAME_MAX, table, info->root, info, ret);
8d419f
 }
8d419f
diff --git a/src/shared/install-printf.h b/src/shared/install-printf.h
8d419f
index d2cccdf66d..60d3a9fc55 100644
8d419f
--- a/src/shared/install-printf.h
8d419f
+++ b/src/shared/install-printf.h
8d419f
@@ -6,7 +6,6 @@
8d419f
 
8d419f
 int install_name_printf(
8d419f
                 UnitFileScope scope,
8d419f
-                const UnitFileInstallInfo *i,
8d419f
+                const UnitFileInstallInfo *info,
8d419f
                 const char *format,
8d419f
-                const char *root,
8d419f
                 char **ret);
8d419f
diff --git a/src/shared/install.c b/src/shared/install.c
8d419f
index a864039f44..f911d527df 100644
8d419f
--- a/src/shared/install.c
8d419f
+++ b/src/shared/install.c
8d419f
@@ -1205,7 +1205,7 @@ static int config_parse_also(
8d419f
                 if (r == 0)
8d419f
                         break;
8d419f
 
8d419f
-                r = install_name_printf(ctx->scope, info, word, info->root, &printed);
8d419f
+                r = install_name_printf(ctx->scope, info, word, &printed);
8d419f
                 if (r < 0)
8d419f
                         return log_syntax(unit, LOG_WARNING, filename, line, r,
8d419f
                                           "Failed to resolve unit name in Also=\"%s\": %m", word);
8d419f
@@ -1254,7 +1254,7 @@ static int config_parse_default_instance(
8d419f
                 return log_syntax(unit, LOG_WARNING, filename, line, 0,
8d419f
                                   "DefaultInstance= only makes sense for template units, ignoring.");
8d419f
 
8d419f
-        r = install_name_printf(ctx->scope, info, rvalue, info->root, &printed);
8d419f
+        r = install_name_printf(ctx->scope, info, rvalue, &printed);
8d419f
         if (r < 0)
8d419f
                 return log_syntax(unit, LOG_WARNING, filename, line, r,
8d419f
                                   "Failed to resolve instance name in DefaultInstance=\"%s\": %m", rvalue);
8d419f
@@ -1850,7 +1850,7 @@ static int install_info_symlink_alias(
8d419f
         STRV_FOREACH(s, info->aliases) {
8d419f
                 _cleanup_free_ char *alias_path = NULL, *dst = NULL, *dst_updated = NULL;
8d419f
 
8d419f
-                q = install_name_printf(scope, info, *s, info->root, &dst);
8d419f
+                q = install_name_printf(scope, info, *s, &dst);
8d419f
                 if (q < 0) {
8d419f
                         unit_file_changes_add(changes, n_changes, q, *s, NULL);
8d419f
                         r = r < 0 ? r : q;
8d419f
@@ -1940,7 +1940,7 @@ static int install_info_symlink_wants(
8d419f
         STRV_FOREACH(s, list) {
8d419f
                 _cleanup_free_ char *dst = NULL;
8d419f
 
8d419f
-                q = install_name_printf(scope, info, *s, info->root, &dst);
8d419f
+                q = install_name_printf(scope, info, *s, &dst);
8d419f
                 if (q < 0) {
8d419f
                         unit_file_changes_add(changes, n_changes, q, *s, NULL);
8d419f
                         return q;
8d419f
diff --git a/src/test/test-load-fragment.c b/src/test/test-load-fragment.c
8d419f
index 9df53cec2b..a87c654f4e 100644
8d419f
--- a/src/test/test-load-fragment.c
8d419f
+++ b/src/test/test-load-fragment.c
8d419f
@@ -531,7 +531,7 @@ TEST(install_printf, .sd_booted = true) {
8d419f
                 _cleanup_free_ char *t = NULL,                          \
8d419f
                         *d1 = ASSERT_PTR(strdup(i.name)),               \
8d419f
                         *d2 = ASSERT_PTR(strdup(i.path));               \
8d419f
-                int r = install_name_printf(scope, &src, pattern, NULL, &t); \
8d419f
+                int r = install_name_printf(scope, &src, pattern, &t);  \
8d419f
                 assert_se(result ? r >= 0 : r < 0);                     \
8d419f
                 memzero(i.name, strlen(i.name));                        \
8d419f
                 memzero(i.path, strlen(i.path));                        \