summaryrefslogtreecommitdiff
path: root/src/login/logind-acl.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2013-07-16 23:05:02 +0200
committerTom Gundersen <teg@jklm.no>2013-07-17 01:36:03 +0200
commitdb0c1e3bd39c9151ba4ac8e029ec77a4ec923bd1 (patch)
treefd323684d799a7763887c33a7b79ec6eec6ade0a /src/login/logind-acl.c
parent6b78df0a6ec75f25705a0f78ef895b95ab75a7ea (diff)
logind-acl: use macros
Simplify by using FOREACH_DIRENT and _cleanup_closedir_ macros.
Diffstat (limited to 'src/login/logind-acl.c')
-rw-r--r--src/login/logind-acl.c11
1 files changed, 2 insertions, 9 deletions
diff --git a/src/login/logind-acl.c b/src/login/logind-acl.c
index c0ff509377..390b4b2885 100644
--- a/src/login/logind-acl.c
+++ b/src/login/logind-acl.c
@@ -183,7 +183,7 @@ int devnode_acl_all(struct udev *udev,
Set *nodes;
Iterator i;
char *n;
- DIR *dir;
+ _cleanup_closedir_ DIR *dir = NULL;
struct dirent *dent;
int r;
@@ -258,35 +258,28 @@ int devnode_acl_all(struct udev *udev,
* these devices are not known to the kernel at this moment */
dir = opendir("/run/udev/static_node-tags/uaccess");
if (dir) {
- for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) {
+ FOREACH_DIRENT(dent, dir, r = -errno; goto finish) {
_cleanup_free_ char *unescaped_devname = NULL;
- if (dent->d_name[0] == '.')
- continue;
-
unescaped_devname = cunescape(dent->d_name);
if (unescaped_devname == NULL) {
r = -ENOMEM;
- closedir(dir);
goto finish;
}
n = strappend("/dev/", unescaped_devname);
if (!n) {
r = -ENOMEM;
- closedir(dir);
goto finish;
}
log_debug("Found static node %s for seat %s", n, seat);
r = set_put(nodes, n);
if (0 && r < 0 && r != -EEXIST) {
- closedir(dir);
goto finish;
} else
r = 0;
}
- closedir(dir);
}
SET_FOREACH(n, nodes, i) {