From: Andreas Schwab Date: Wed, 9 May 2001 16:36:11 +0000 (+0000) Subject: * sysdeps/unix/readdir.c: Make sure we don't modify errno when we reached EOF. X-Git-Tag: cvs/pre-lgplv2_1~208 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=a92544ca120238d4da72e27e5a10012f8bf75955;p=glibc.git * sysdeps/unix/readdir.c: Make sure we don't modify errno when we reached EOF. --- diff --git a/sysdeps/unix/readdir.c b/sysdeps/unix/readdir.c index 4cb66ba2e4..312660a0c4 100644 --- a/sysdeps/unix/readdir.c +++ b/sysdeps/unix/readdir.c @@ -39,6 +39,7 @@ DIRENT_TYPE * __READDIR (DIR *dirp) { DIRENT_TYPE *dp; + int saved_errno = errno; __libc_lock_lock (dirp->lock); @@ -63,6 +64,9 @@ __READDIR (DIR *dirp) bytes = __GETDENTS (dirp->fd, dirp->data, maxread); if (bytes <= 0) { + /* Don't modifiy errno when reaching EOF. */ + if (bytes == 0) + __set_errno (saved_errno); dp = NULL; break; }