(is_empty_dir): Don't let a failing closedir
authorJim Meyering <jim@meyering.net>
Sun, 30 Mar 2003 15:02:55 +0000 (15:02 +0000)
committerJim Meyering <jim@meyering.net>
Sun, 30 Mar 2003 15:02:55 +0000 (15:02 +0000)
clobber errno.  Spotted by Arnold Robbins.

src/remove.c

index a0ad0a124b33d9f9d05998b056affd09f4ac5ec3..21c5ac0ac3cef085518d77f7863538bfa3db3d09 100644 (file)
@@ -527,8 +527,9 @@ is_empty_dir (char const *dir)
       dp = readdir (dirp);
       if (dp == NULL)
        {
+         int saved_errno = errno;
          closedir (dirp);
-         return errno == 0 ? true : false;
+         return saved_errno == 0 ? true : false;
        }
 
       f = dp->d_name;