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