install: small refactor to combine two function calls into one function
Combine consecutive function calls of install_info_discover and install_info_may_process into one short helper function.
This commit is contained in:
parent
4c9565eea5
commit
1e475a0ab4
|
@ -1676,6 +1676,25 @@ static int install_info_discover(
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int install_info_discover_and_check(
|
||||||
|
UnitFileScope scope,
|
||||||
|
InstallContext *c,
|
||||||
|
const LookupPaths *paths,
|
||||||
|
const char *name,
|
||||||
|
SearchFlags flags,
|
||||||
|
UnitFileInstallInfo **ret,
|
||||||
|
UnitFileChange **changes,
|
||||||
|
size_t *n_changes) {
|
||||||
|
|
||||||
|
int r;
|
||||||
|
|
||||||
|
r = install_info_discover(scope, c, paths, name, flags, ret, changes, n_changes);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
return install_info_may_process(ret ? *ret : NULL, paths, changes, n_changes);
|
||||||
|
}
|
||||||
|
|
||||||
static int install_info_symlink_alias(
|
static int install_info_symlink_alias(
|
||||||
UnitFileInstallInfo *i,
|
UnitFileInstallInfo *i,
|
||||||
const LookupPaths *paths,
|
const LookupPaths *paths,
|
||||||
|
@ -2399,11 +2418,8 @@ int unit_file_add_dependency(
|
||||||
if (!config_path)
|
if (!config_path)
|
||||||
return -ENXIO;
|
return -ENXIO;
|
||||||
|
|
||||||
r = install_info_discover(scope, &c, &paths, target, SEARCH_FOLLOW_CONFIG_SYMLINKS,
|
r = install_info_discover_and_check(scope, &c, &paths, target, SEARCH_FOLLOW_CONFIG_SYMLINKS,
|
||||||
&target_info, changes, n_changes);
|
&target_info, changes, n_changes);
|
||||||
if (r < 0)
|
|
||||||
return r;
|
|
||||||
r = install_info_may_process(target_info, &paths, changes, n_changes);
|
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
|
@ -2412,11 +2428,8 @@ int unit_file_add_dependency(
|
||||||
STRV_FOREACH(f, files) {
|
STRV_FOREACH(f, files) {
|
||||||
char ***l;
|
char ***l;
|
||||||
|
|
||||||
r = install_info_discover(scope, &c, &paths, *f, SEARCH_FOLLOW_CONFIG_SYMLINKS,
|
r = install_info_discover_and_check(scope, &c, &paths, *f, SEARCH_FOLLOW_CONFIG_SYMLINKS,
|
||||||
&i, changes, n_changes);
|
&i, changes, n_changes);
|
||||||
if (r < 0)
|
|
||||||
return r;
|
|
||||||
r = install_info_may_process(i, &paths, changes, n_changes);
|
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
|
@ -2467,11 +2480,8 @@ int unit_file_enable(
|
||||||
return -ENXIO;
|
return -ENXIO;
|
||||||
|
|
||||||
STRV_FOREACH(f, files) {
|
STRV_FOREACH(f, files) {
|
||||||
r = install_info_discover(scope, &c, &paths, *f, SEARCH_LOAD|SEARCH_FOLLOW_CONFIG_SYMLINKS,
|
r = install_info_discover_and_check(scope, &c, &paths, *f, SEARCH_LOAD|SEARCH_FOLLOW_CONFIG_SYMLINKS,
|
||||||
&i, changes, n_changes);
|
&i, changes, n_changes);
|
||||||
if (r < 0)
|
|
||||||
return r;
|
|
||||||
r = install_info_may_process(i, &paths, changes, n_changes);
|
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
|
@ -2585,10 +2595,7 @@ int unit_file_set_default(
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
r = install_info_discover(scope, &c, &paths, name, 0, &i, changes, n_changes);
|
r = install_info_discover_and_check(scope, &c, &paths, name, 0, &i, changes, n_changes);
|
||||||
if (r < 0)
|
|
||||||
return r;
|
|
||||||
r = install_info_may_process(i, &paths, changes, n_changes);
|
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
|
@ -3089,22 +3096,14 @@ static int preset_prepare_one(
|
||||||
if (instance_name_list) {
|
if (instance_name_list) {
|
||||||
char **s;
|
char **s;
|
||||||
STRV_FOREACH(s, instance_name_list) {
|
STRV_FOREACH(s, instance_name_list) {
|
||||||
r = install_info_discover(scope, plus, paths, *s, SEARCH_LOAD|SEARCH_FOLLOW_CONFIG_SYMLINKS,
|
r = install_info_discover_and_check(scope, plus, paths, *s, SEARCH_LOAD|SEARCH_FOLLOW_CONFIG_SYMLINKS,
|
||||||
&i, changes, n_changes);
|
&i, changes, n_changes);
|
||||||
if (r < 0)
|
|
||||||
return r;
|
|
||||||
|
|
||||||
r = install_info_may_process(i, paths, changes, n_changes);
|
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
r = install_info_discover(scope, plus, paths, name, SEARCH_LOAD|SEARCH_FOLLOW_CONFIG_SYMLINKS,
|
r = install_info_discover_and_check(scope, plus, paths, name, SEARCH_LOAD|SEARCH_FOLLOW_CONFIG_SYMLINKS,
|
||||||
&i, changes, n_changes);
|
&i, changes, n_changes);
|
||||||
if (r < 0)
|
|
||||||
return r;
|
|
||||||
|
|
||||||
r = install_info_may_process(i, paths, changes, n_changes);
|
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue