From a92544ca120238d4da72e27e5a10012f8bf75955 Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Wed, 9 May 2001 16:36:11 +0000 Subject: * sysdeps/unix/readdir.c: Make sure we don't modify errno when we reached EOF. --- sysdeps/unix/readdir.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'sysdeps/unix') 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; } -- cgit 1.4.1