]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shared/bus-unit-util: define helper for Paths property
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 27 Jun 2025 14:05:33 +0000 (16:05 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 3 Jul 2025 17:35:33 +0000 (19:35 +0200)
src/shared/bus-unit-util.c

index c7fce7e77fee0136312fbbb7890a2fea71ce1b42..0fdf946f97ea3074443cf538c1e8e5e35bc5d6e7 100644 (file)
@@ -2069,6 +2069,19 @@ static int bus_append_protect_hostname(sd_bus_message *m, const char *field, con
         return 1;
 }
 
+static int bus_append_paths(sd_bus_message *m, const char *field, const char *eq) {
+        int r;
+
+        if (isempty(eq))
+                r = sd_bus_message_append(m, "(sv)", "Paths", "a(ss)", 0);
+        else
+                r = sd_bus_message_append(m, "(sv)", "Paths", "a(ss)", 1, field, eq);
+        if (r < 0)
+                return bus_log_create_error(r);
+
+        return 1;
+}
+
 static int bus_append_cgroup_property(sd_bus_message *m, const char *field, const char *eq) {
         if (STR_IN_SET(field, "DevicePolicy",
                               "Slice",
@@ -2492,16 +2505,8 @@ static int bus_append_path_property(sd_bus_message *m, const char *field, const
                               "PathExistsGlob",
                               "PathChanged",
                               "PathModified",
-                              "DirectoryNotEmpty")) {
-                if (isempty(eq))
-                        r = sd_bus_message_append(m, "(sv)", "Paths", "a(ss)", 0);
-                else
-                        r = sd_bus_message_append(m, "(sv)", "Paths", "a(ss)", 1, field, eq);
-                if (r < 0)
-                        return bus_log_create_error(r);
-
-                return 1;
-        }
+                              "DirectoryNotEmpty"))
+                return bus_append_paths(m, field, eq);
 
         if (STR_IN_SET(field, "TriggerLimitBurst", "PollLimitBurst"))
                 return bus_append_safe_atou(m, field, eq);