]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udevadm: cleanup_dir: use dot_or_dot_dot()
authorMartin Wilck <mwilck@suse.com>
Fri, 21 Jan 2022 09:44:26 +0000 (10:44 +0100)
committerMartin Wilck <mwilck@suse.com>
Fri, 21 Jan 2022 12:31:42 +0000 (13:31 +0100)
which is safer than just checking dent[0].
Also, fix two style issues.

src/udev/udevadm-info.c

index 740434bb419bfe8e3be146f12406ad76e9842a7e..cb5e74a1b61f59860c3b1e117d558cf98da13340 100644 (file)
@@ -232,12 +232,14 @@ static void cleanup_dir(DIR *dir, mode_t mask, int depth) {
         if (depth <= 0)
                 return;
 
+        assert(dir);
+
         FOREACH_DIRENT_ALL(dent, dir, break) {
                 struct stat stats;
 
-                if (dent->d_name[0] == '.')
+                if (dot_or_dot_dot(dent->d_name))
                         continue;
-                if (fstatat(dirfd(dir), dent->d_name, &stats, AT_SYMLINK_NOFOLLOW) != 0)
+                if (fstatat(dirfd(dir), dent->d_name, &stats, AT_SYMLINK_NOFOLLOW) < 0)
                         continue;
                 if ((stats.st_mode & mask) != 0)
                         continue;