From: Jim Meyering Date: Wed, 23 Nov 2005 13:35:09 +0000 (+0000) Subject: (fdopendir): Don't change errno when returning non-NULL. X-Git-Tag: v6.0~1268 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e8609798de7b1085a11afd33064a08ff18f77cbe;p=thirdparty%2Fcoreutils.git (fdopendir): Don't change errno when returning non-NULL. --- diff --git a/lib/openat.c b/lib/openat.c index 2300208f80..1bd4d73c82 100644 --- a/lib/openat.c +++ b/lib/openat.c @@ -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. */