core/dbus-unit: reduce scope of iterator variables

This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2021-02-12 10:25:13 +01:00
parent ff68472a20
commit 95d1e21e90

View File

@@ -811,7 +811,6 @@ static int property_get_refs(
sd_bus_error *error) {
Unit *u = userdata;
const char *i;
int r;
assert(bus);
@@ -821,15 +820,15 @@ static int property_get_refs(
if (r < 0)
return r;
for (i = sd_bus_track_first(u->bus_track); i; i = sd_bus_track_next(u->bus_track)) {
int c, k;
for (const char *i = sd_bus_track_first(u->bus_track); i; i = sd_bus_track_next(u->bus_track)) {
int c;
c = sd_bus_track_count_name(u->bus_track, i);
if (c < 0)
return c;
/* Add the item multiple times if the ref count for each is above 1 */
for (k = 0; k < c; k++) {
for (int k = 0; k < c; k++) {
r = sd_bus_message_append(reply, "s", i);
if (r < 0)
return r;