mirror of
https://github.com/systemd/systemd.git
synced 2024-11-01 17:51:22 +03:00
shared: split out code for adding multiple names to sd_bus_track object
Let's introduce a new call bus_track_add_name_many() that adds a string list to a tracking object.
This commit is contained in:
parent
afc402b76a
commit
984794baf4
@ -1185,7 +1185,6 @@ void bus_track_serialize(sd_bus_track *t, FILE *f, const char *prefix) {
|
||||
}
|
||||
|
||||
int bus_track_coldplug(Manager *m, sd_bus_track **t, bool recursive, char **l) {
|
||||
char **i;
|
||||
int r = 0;
|
||||
|
||||
assert(m);
|
||||
@ -1207,16 +1206,7 @@ int bus_track_coldplug(Manager *m, sd_bus_track **t, bool recursive, char **l) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = 0;
|
||||
STRV_FOREACH(i, l) {
|
||||
int k;
|
||||
|
||||
k = sd_bus_track_add_name(*t, *i);
|
||||
if (k < 0)
|
||||
r = k;
|
||||
}
|
||||
|
||||
return r;
|
||||
return bus_track_add_name_many(*t, l);
|
||||
}
|
||||
|
||||
int bus_verify_manage_units_async(Manager *m, sd_bus_message *call, sd_bus_error *error) {
|
||||
|
@ -1583,3 +1583,22 @@ int bus_property_get_rlimit(
|
||||
|
||||
return sd_bus_message_append(reply, "t", u);
|
||||
}
|
||||
|
||||
int bus_track_add_name_many(sd_bus_track *t, char **l) {
|
||||
int r = 0;
|
||||
char **i;
|
||||
|
||||
assert(t);
|
||||
|
||||
/* Continues adding after failure, and returns the first failure. */
|
||||
|
||||
STRV_FOREACH(i, l) {
|
||||
int k;
|
||||
|
||||
k = sd_bus_track_add_name(t, *i);
|
||||
if (k < 0 && r >= 0)
|
||||
r = k;
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
@ -159,3 +159,5 @@ int bus_path_encode_unique(sd_bus *b, const char *prefix, const char *sender_id,
|
||||
int bus_path_decode_unique(const char *path, const char *prefix, char **ret_sender, char **ret_external);
|
||||
|
||||
int bus_property_get_rlimit(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error);
|
||||
|
||||
int bus_track_add_name_many(sd_bus_track *t, char **l);
|
||||
|
Loading…
Reference in New Issue
Block a user