]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: drop redundant assignment of UNIT_MERGED in unit_load_fragment()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 13 Aug 2023 05:56:49 +0000 (14:56 +0900)
committerLuca Boccassi <luca.boccassi@gmail.com>
Sun, 13 Aug 2023 11:56:08 +0000 (12:56 +0100)
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

index 219a84a234df7e280b40ff2bad1bceb5ea0fbe86..ceca070e797fb008bad4978529137395592fd1ed 100644 (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) {