From: Mike Yuan Date: Thu, 26 Sep 2024 15:29:30 +0000 (+0200) Subject: shared/bus-map-properties: move bus_map_job_id() from wait-for-units X-Git-Tag: v257-rc1~359^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=cdf684fc00cb44a693ee077c19f89aa09b54de61;p=thirdparty%2Fsystemd.git shared/bus-map-properties: move bus_map_job_id() from wait-for-units --- diff --git a/src/shared/bus-map-properties.c b/src/shared/bus-map-properties.c index aa17ded5a31..a6cd7528949 100644 --- a/src/shared/bus-map-properties.c +++ b/src/shared/bus-map-properties.c @@ -10,6 +10,8 @@ int bus_map_id128(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_err sd_id128_t *p = userdata; int r; + assert(m); + r = bus_message_read_id128(m, p); if (r < 0) return bus_log_parse_error_debug(r); @@ -21,6 +23,8 @@ int bus_map_strv_sort(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus char ***p = ASSERT_PTR(userdata); int r; + assert(m); + r = sd_bus_message_read_strv_extend(m, p); if (r < 0) return bus_log_parse_error_debug(r); @@ -29,6 +33,14 @@ int bus_map_strv_sort(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus return 0; } +int bus_map_job_id(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_error *error, void *userdata) { + uint32_t *p = ASSERT_PTR(userdata); + + assert(m); + + return sd_bus_message_read(m, "(uo)", p, /* path = */ NULL); +} + static int map_basic(sd_bus_message *m, unsigned flags, void *userdata) { char type; int r; diff --git a/src/shared/bus-map-properties.h b/src/shared/bus-map-properties.h index e9f4a92ff23..183e9722f1e 100644 --- a/src/shared/bus-map-properties.h +++ b/src/shared/bus-map-properties.h @@ -19,6 +19,7 @@ enum { int bus_map_id128(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_error *error, void *userdata); int bus_map_strv_sort(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_error *error, void *userdata); +int bus_map_job_id(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_error *error, void *userdata); int bus_message_map_all_properties(sd_bus_message *m, const struct bus_properties_map *map, unsigned flags, sd_bus_error *error, void *userdata); int bus_map_all_properties(sd_bus *bus, const char *destination, const char *path, const struct bus_properties_map *map, diff --git a/src/shared/bus-wait-for-units.c b/src/shared/bus-wait-for-units.c index f16fe51e6e1..20bb7d0405c 100644 --- a/src/shared/bus-wait-for-units.c +++ b/src/shared/bus-wait-for-units.c @@ -202,25 +202,11 @@ static void wait_for_item_check_ready(WaitForItem *item) { bus_wait_for_units_check_ready(d); } -static int property_map_job_id( - sd_bus *bus, - const char *member, - sd_bus_message *m, - sd_bus_error *error, - void *userdata) { - - uint32_t *job_id = ASSERT_PTR(userdata); - - assert(m); - - return sd_bus_message_read(m, "(uo)", job_id, /* path = */ NULL); -} - static int wait_for_item_parse_properties(WaitForItem *item, sd_bus_message *m) { static const struct bus_properties_map map[] = { { "ActiveState", "s", NULL, offsetof(WaitForItem, active_state) }, - { "Job", "(uo)", property_map_job_id, offsetof(WaitForItem, job_id) }, + { "Job", "(uo)", bus_map_job_id, offsetof(WaitForItem, job_id) }, { "CleanResult", "s", NULL, offsetof(WaitForItem, clean_result) }, { "LiveMountResult", "s", NULL, offsetof(WaitForItem, live_mount_result) }, {}