]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(fdopendir): Don't change errno when returning non-NULL.
authorJim Meyering <jim@meyering.net>
Wed, 23 Nov 2005 13:35:09 +0000 (13:35 +0000)
committerJim Meyering <jim@meyering.net>
Wed, 23 Nov 2005 13:35:09 +0000 (13:35 +0000)
lib/openat.c

index 2300208f80dbd2b2786528963e8a2e073008ce75..1bd4d73c827faa8ca5fd3fce0f4677bf734d3698 100644 (file)
@@ -232,7 +232,7 @@ fdopendir (int fd)
     char *proc_file;
     BUILD_PROC_NAME (proc_file, fd, ".");
     dir = opendir (proc_file);
-    saved_errno = errno;
+    saved_errno = (dir == NULL ? errno : 0);
     /* If the syscall succeeded, or if it failed with an unexpected
        errno value, then return right away.  Otherwise, fall through
        and resort to using save_cwd/restore_cwd.  */