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