diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-12-07 15:02:55 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-12-15 16:19:13 +0100 |
commit | c7f0d9e5acef3f62db3640d5ab7446241c022b35 (patch) | |
tree | d8312bdb6ba90d0277306ba8f3b08dc391759e5a /src/login/logind-dbus.c | |
parent | 372e8592c6e3a891174344be0899a91769ef61af (diff) | |
download | systemd-c7f0d9e5acef3f62db3640d5ab7446241c022b35.tar.gz |
tree-wide: make FOREACH_DIRENT_ALL define the iterator variable
The variable is not useful outside of the loop (it'll always be null
after the loop is finished), so we can declare it inline in the loop.
This saves one variable declaration and reduces the chances that somebody
tries to use the variable outside of the loop.
For consistency, 'de' is used everywhere for the var name.
Diffstat (limited to 'src/login/logind-dbus.c')
-rw-r--r-- | src/login/logind-dbus.c | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c index 331dcd2a05..cc5214c2eb 100644 --- a/src/login/logind-dbus.c +++ b/src/login/logind-dbus.c @@ -1370,9 +1370,7 @@ static int flush_devices(Manager *m) { if (!d) { if (errno != ENOENT) log_warning_errno(errno, "Failed to open /etc/udev/rules.d: %m"); - } else { - struct dirent *de; - + } else FOREACH_DIRENT_ALL(de, d, break) { if (!dirent_is_file(de)) continue; @@ -1386,7 +1384,6 @@ static int flush_devices(Manager *m) { if (unlinkat(dirfd(d), de->d_name, 0) < 0) log_warning_errno(errno, "Failed to unlink %s: %m", de->d_name); } - } return trigger_device(m, NULL); } |