diff --git a/src/shared/bus-util.c b/src/shared/bus-util.c index 5c76346fc3..99be9d5395 100644 --- a/src/shared/bus-util.c +++ b/src/shared/bus-util.c @@ -700,16 +700,15 @@ int bus_track_add_name_many(sd_bus_track *t, char **l) { int bus_track_to_strv(sd_bus_track *t, char ***ret) { _cleanup_strv_free_ char **subscribed = NULL; - int r = 0; + int r; assert(ret); for (const char *n = sd_bus_track_first(t); n; n = sd_bus_track_next(t)) { - r = sd_bus_track_count_name(t, n); - if (r < 0) - return r; + int c = sd_bus_track_count_name(t, n); + assert(c >= 0); - for (int j = 0; j < r; j++) { + for (int j = 0; j < c; j++) { r = strv_extend(&subscribed, n); if (r < 0) return r; @@ -717,7 +716,7 @@ int bus_track_to_strv(sd_bus_track *t, char ***ret) { } *ret = TAKE_PTR(subscribed); - return r; + return 0; } int bus_open_system_watch_bind_with_description(sd_bus **ret, const char *description) {