From 7a5eb9d03de6be39bab15e9ddfca7ff9d7d90df3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Fri, 27 Jun 2025 16:05:33 +0200 Subject: [PATCH] shared/bus-unit-util: define helper for Paths property --- src/shared/bus-unit-util.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/shared/bus-unit-util.c b/src/shared/bus-unit-util.c index c7fce7e77fe..0fdf946f97e 100644 --- a/src/shared/bus-unit-util.c +++ b/src/shared/bus-unit-util.c @@ -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); -- 2.47.3