]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shared/install: stop passing duplicate root argument to install_name_printf()
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 17 Mar 2022 09:16:30 +0000 (10:16 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 29 Mar 2022 14:17:56 +0000 (16:17 +0200)
All callers were just passing info + info->root, we can simplify this.

src/shared/install-printf.c
src/shared/install-printf.h
src/shared/install.c
src/test/test-load-fragment.c

index 571c4818e2b71b39c3e75e34211fa8814ff5d93d..4c0eb3ce61df6bc63df60fb23718a5f2ac3f51c4 100644 (file)
@@ -99,9 +99,8 @@ static int specifier_last_component(char specifier, const void *data, const char
 
 int install_name_printf(
                 UnitFileScope scope,
-                const UnitFileInstallInfo *i,
+                const UnitFileInstallInfo *info,
                 const char *format,
-                const char *root,
                 char **ret) {
         /* This is similar to unit_name_printf() */
 
@@ -118,9 +117,9 @@ int install_name_printf(
                 {}
         };
 
-        assert(i);
+        assert(info);
         assert(format);
         assert(ret);
 
-        return specifier_printf(format, UNIT_NAME_MAX, table, root, i, ret);
+        return specifier_printf(format, UNIT_NAME_MAX, table, info->root, info, ret);
 }
index d2cccdf66d999ae07a468bc90490e57b427be272..60d3a9fc55c89995b271245658be1b7a30945c7e 100644 (file)
@@ -6,7 +6,6 @@
 
 int install_name_printf(
                 UnitFileScope scope,
-                const UnitFileInstallInfo *i,
+                const UnitFileInstallInfo *info,
                 const char *format,
-                const char *root,
                 char **ret);
index 91e38c57ccbc802e20c9a693a34e90c0896c1ad7..d5e197928025fae0cb2779db9cd13fb3f502ac34 100644 (file)
@@ -1203,7 +1203,7 @@ static int config_parse_also(
                 if (r == 0)
                         break;
 
-                r = install_name_printf(ctx->scope, info, word, info->root, &printed);
+                r = install_name_printf(ctx->scope, info, word, &printed);
                 if (r < 0)
                         return log_syntax(unit, LOG_WARNING, filename, line, r,
                                           "Failed to resolve unit name in Also=\"%s\": %m", word);
@@ -1252,7 +1252,7 @@ static int config_parse_default_instance(
                 return log_syntax(unit, LOG_WARNING, filename, line, 0,
                                   "DefaultInstance= only makes sense for template units, ignoring.");
 
-        r = install_name_printf(ctx->scope, info, rvalue, info->root, &printed);
+        r = install_name_printf(ctx->scope, info, rvalue, &printed);
         if (r < 0)
                 return log_syntax(unit, LOG_WARNING, filename, line, r,
                                   "Failed to resolve instance name in DefaultInstance=\"%s\": %m", rvalue);
@@ -1845,7 +1845,7 @@ static int install_info_symlink_alias(
         STRV_FOREACH(s, info->aliases) {
                 _cleanup_free_ char *alias_path = NULL, *dst = NULL, *dst_updated = NULL;
 
-                q = install_name_printf(scope, info, *s, info->root, &dst);
+                q = install_name_printf(scope, info, *s, &dst);
                 if (q < 0) {
                         unit_file_changes_add(changes, n_changes, q, *s, NULL);
                         r = r < 0 ? r : q;
@@ -1935,7 +1935,7 @@ static int install_info_symlink_wants(
         STRV_FOREACH(s, list) {
                 _cleanup_free_ char *dst = NULL;
 
-                q = install_name_printf(scope, info, *s, info->root, &dst);
+                q = install_name_printf(scope, info, *s, &dst);
                 if (q < 0) {
                         unit_file_changes_add(changes, n_changes, q, *s, NULL);
                         return q;
index 40cd7ea7e627c60cc07d8d66fd787e9e6ea6a7b6..52341e5199caa0356ede4ae10469aba8d6692d0c 100644 (file)
@@ -515,7 +515,7 @@ TEST(install_printf, .sd_booted = true) {
                 _cleanup_free_ char *t = NULL,                          \
                         *d1 = ASSERT_PTR(strdup(i.name)),               \
                         *d2 = ASSERT_PTR(strdup(i.path));               \
-                int r = install_name_printf(scope, &src, pattern, NULL, &t); \
+                int r = install_name_printf(scope, &src, pattern, &t);  \
                 assert_se(result ? r >= 0 : r < 0);                     \
                 memzero(i.name, strlen(i.name));                        \
                 memzero(i.path, strlen(i.path));                        \