1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-09 01:18:19 +03:00

core: drop redundant assignment of UNIT_MERGED in unit_load_fragment()

If the unit is merged into another unit, then the load state is already
set in merge_by_names() -> unit_merge(). Let's drop the redundant assignment.
This commit is contained in:
Yu Watanabe 2023-08-13 14:56:49 +09:00 committed by Luca Boccassi
parent e3390a22dc
commit 57ffa99daa

View File

@ -6097,39 +6097,37 @@ int config_parse_restrict_network_interfaces(
return 0;
}
static int merge_by_names(Unit **u, Set *names, const char *id) {
static int merge_by_names(Unit *u, Set *names, const char *id) {
char *k;
int r;
assert(u);
assert(*u);
/* Let's try to add in all names that are aliases of this unit */
while ((k = set_steal_first(names))) {
_cleanup_free_ _unused_ char *free_k = k;
/* First try to merge in the other name into our unit */
r = unit_merge_by_name(*u, k);
r = unit_merge_by_name(u, k);
if (r < 0) {
Unit *other;
/* Hmm, we couldn't merge the other unit into ours? Then let's try it the other way
* round. */
other = manager_get_unit((*u)->manager, k);
other = manager_get_unit(u->manager, k);
if (!other)
return r; /* return previous failure */
r = unit_merge(other, *u);
r = unit_merge(other, u);
if (r < 0)
return r;
*u = other;
return merge_by_names(u, names, NULL);
return merge_by_names(other, names, NULL);
}
if (streq_ptr(id, k))
unit_choose_id(*u, id);
unit_choose_id(u, id);
}
return 0;
@ -6251,15 +6249,7 @@ int unit_load_fragment(Unit *u) {
}
}
Unit *merged = u;
r = merge_by_names(&merged, names, id);
if (r < 0)
return r;
if (merged != u)
u->load_state = UNIT_MERGED;
return 0;
return merge_by_names(u, names, id);
}
void unit_dump_config_items(FILE *f) {