]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core/dbus-unit: remove unneeded else if 37410/head
authorMike Yuan <me@yhndnzj.com>
Thu, 17 Apr 2025 15:33:50 +0000 (17:33 +0200)
committerMike Yuan <me@yhndnzj.com>
Mon, 12 May 2025 16:56:15 +0000 (18:56 +0200)
src/core/dbus-unit.c

index 9080ad93de9927b47afef1107507f20138384ba3..4f45b7c34edfc65551036810384e8362f91057dc 100644 (file)
@@ -2351,8 +2351,9 @@ static int bus_unit_set_transient_property(
                 }
 
                 return 1;
+        }
 
-        } else if (streq(name, "Slice")) {
+        if (streq(name, "Slice")) {
                 Unit *slice;
                 const char *s;
 
@@ -2389,8 +2390,9 @@ static int bus_unit_set_transient_property(
                 }
 
                 return 1;
+        }
 
-        } else if (STR_IN_SET(name, "RequiresMountsFor", "WantsMountsFor")) {
+        if (STR_IN_SET(name, "RequiresMountsFor", "WantsMountsFor")) {
                 _cleanup_strv_free_ char **l = NULL;
 
                 r = sd_bus_message_read_strv(message, &l);
@@ -2421,13 +2423,35 @@ static int bus_unit_set_transient_property(
                 return 1;
         }
 
+        if (streq(name, "AddRef")) {
+                int b;
+
+                /* Why is this called "AddRef" rather than just "Ref", or "Reference"? There's already a "Ref()" method
+                 * on the Unit interface, and it's probably not a good idea to expose a property and a method on the
+                 * same interface (well, strictly speaking AddRef isn't exposed as full property, we just read it for
+                 * transient units, but still). And "References" and "ReferencedBy" is already used as unit reference
+                 * dependency type, hence let's not confuse things with that.
+                 *
+                 * Note that we don't actually add the reference to the bus track. We do that only after the setup of
+                 * the transient unit is complete, so that setting this property multiple times in the same transient
+                 * unit creation call doesn't count as individual references. */
+
+                r = sd_bus_message_read(message, "b", &b);
+                if (r < 0)
+                        return r;
+
+                if (!UNIT_WRITE_FLAGS_NOOP(flags))
+                        u->bus_track_add = b;
+
+                return 1;
+        }
+
         if (streq(name, "RequiresOverridable"))
                 d = UNIT_REQUIRES; /* redirect for obsolete unit dependency type */
         else if (streq(name, "RequisiteOverridable"))
                 d = UNIT_REQUISITE; /* same here */
         else
                 d = unit_dependency_from_string(name);
-
         if (d >= 0) {
                 const char *other;
 
@@ -2481,29 +2505,6 @@ static int bus_unit_set_transient_property(
                         return r;
 
                 return 1;
-
-        } else if (streq(name, "AddRef")) {
-
-                int b;
-
-                /* Why is this called "AddRef" rather than just "Ref", or "Reference"? There's already a "Ref()" method
-                 * on the Unit interface, and it's probably not a good idea to expose a property and a method on the
-                 * same interface (well, strictly speaking AddRef isn't exposed as full property, we just read it for
-                 * transient units, but still). And "References" and "ReferencedBy" is already used as unit reference
-                 * dependency type, hence let's not confuse things with that.
-                 *
-                 * Note that we don't actually add the reference to the bus track. We do that only after the setup of
-                 * the transient unit is complete, so that setting this property multiple times in the same transient
-                 * unit creation call doesn't count as individual references. */
-
-                r = sd_bus_message_read(message, "b", &b);
-                if (r < 0)
-                        return r;
-
-                if (!UNIT_WRITE_FLAGS_NOOP(flags))
-                        u->bus_track_add = b;
-
-                return 1;
         }
 
         return 0;