* sysdeps/unix/readdir.c: Make sure we don't modify errno when we reached EOF.

This commit is contained in:
Andreas Schwab 2001-05-09 16:36:11 +00:00
parent 4ceae91566
commit a92544ca12

View File

@ -39,6 +39,7 @@ DIRENT_TYPE *
__READDIR (DIR *dirp) __READDIR (DIR *dirp)
{ {
DIRENT_TYPE *dp; DIRENT_TYPE *dp;
int saved_errno = errno;
__libc_lock_lock (dirp->lock); __libc_lock_lock (dirp->lock);
@ -63,6 +64,9 @@ __READDIR (DIR *dirp)
bytes = __GETDENTS (dirp->fd, dirp->data, maxread); bytes = __GETDENTS (dirp->fd, dirp->data, maxread);
if (bytes <= 0) if (bytes <= 0)
{ {
/* Don't modifiy errno when reaching EOF. */
if (bytes == 0)
__set_errno (saved_errno);
dp = NULL; dp = NULL;
break; break;
} }