From: Mike Yuan Date: Tue, 16 Apr 2024 06:53:14 +0000 (+0800) Subject: core/dbus: modernize bus_foreach_bus X-Git-Tag: v256-rc1~121^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8c8687852aaa96f5f486ae14afc5c21f62535d00;p=thirdparty%2Fsystemd.git core/dbus: modernize bus_foreach_bus --- diff --git a/src/core/dbus.c b/src/core/dbus.c index a336b04daf3..1c6f6fc8b38 100644 --- a/src/core/dbus.c +++ b/src/core/dbus.c @@ -1113,31 +1113,29 @@ int bus_foreach_bus( int (*send_message)(sd_bus *bus, void *userdata), void *userdata) { - sd_bus *b; - int r, ret = 0; + int r = 0; + + assert(m); + assert(send_message); /* Send to all direct buses, unconditionally */ + sd_bus *b; SET_FOREACH(b, m->private_buses) { /* Don't bother with enqueuing these messages to clients that haven't started yet */ if (sd_bus_is_ready(b) <= 0) continue; - r = send_message(b, userdata); - if (r < 0) - ret = r; + RET_GATHER(r, send_message(b, userdata)); } /* Send to API bus, but only if somebody is subscribed */ if (m->api_bus && (sd_bus_track_count(m->subscribed) > 0 || - sd_bus_track_count(subscribed2) > 0)) { - r = send_message(m->api_bus, userdata); - if (r < 0) - ret = r; - } + sd_bus_track_count(subscribed2) > 0)) + RET_GATHER(r, send_message(m->api_bus, userdata)); - return ret; + return r; } void bus_track_serialize(sd_bus_track *t, FILE *f, const char *prefix) {