From 57ffa99daae30375ec72a4c998d9c5b74a1f9023 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Sun, 13 Aug 2023 14:56:49 +0900 Subject: [PATCH] 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. --- src/core/load-fragment.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c index 219a84a234d..ceca070e797 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -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) {