summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwtchang%redhat.com <devnull@localhost>2005-03-09 22:52:00 +0000
committerwtchang%redhat.com <devnull@localhost>2005-03-09 22:52:00 +0000
commit9a39cef1ca6f9469a12013eacbe274bda15f72e3 (patch)
treea278a44d8ad48f7b21bf7014321bceb50d14f5f1
parent785d211d21cf13dc321d5de2bc6ee0fe6de53417 (diff)
downloadnspr-hg-9a39cef1ca6f9469a12013eacbe274bda15f72e3.tar.gz
Bugzilla Bug 285286: PR_ReadDir reported the wrong error code when the
end of directory was reached. We need to set errno to 0 before calling readdir and mapping error 0 to PR_NO_MORE_FILES_ERROR. The patch is contributed by Mathieu Poumeyrol <poumeyrol@idm.fr>. r-wtc,bryner. Modified Files: beos_errors.c bfile.c unix.c unix_errors.c ptio.c Tag: NSPRPUB_PRE_4_2_CLIENT_BRANCH
-rw-r--r--pr/src/md/beos/beos_errors.c1
-rw-r--r--pr/src/md/beos/bfile.c1
-rw-r--r--pr/src/md/unix/unix.c1
-rw-r--r--pr/src/md/unix/unix_errors.c1
-rw-r--r--pr/src/pthreads/ptio.c1
5 files changed, 5 insertions, 0 deletions
diff --git a/pr/src/md/beos/beos_errors.c b/pr/src/md/beos/beos_errors.c
index 4882594b..bfb44eb7 100644
--- a/pr/src/md/beos/beos_errors.c
+++ b/pr/src/md/beos/beos_errors.c
@@ -90,6 +90,7 @@ void _MD_unix_readdir_error(int err)
{
switch (err) {
+ case 0:
case ENOENT:
PR_SetError(PR_NO_MORE_FILES_ERROR, err);
break;
diff --git a/pr/src/md/beos/bfile.c b/pr/src/md/beos/bfile.c
index b67c97f1..103fb8ef 100644
--- a/pr/src/md/beos/bfile.c
+++ b/pr/src/md/beos/bfile.c
@@ -69,6 +69,7 @@ int err;
/*
* XXX: readdir() is not MT-safe
*/
+ _MD_ERRNO() = 0;
de = readdir(md->d);
if (!de) {
diff --git a/pr/src/md/unix/unix.c b/pr/src/md/unix/unix.c
index 7ed6f0f9..eb73f053 100644
--- a/pr/src/md/unix/unix.c
+++ b/pr/src/md/unix/unix.c
@@ -177,6 +177,7 @@ int err;
* XXX: readdir() is not MT-safe. There is an MT-safe version
* readdir_r() on some systems.
*/
+ _MD_ERRNO() = 0;
de = readdir(d->d);
if (!de) {
err = _MD_ERRNO();
diff --git a/pr/src/md/unix/unix_errors.c b/pr/src/md/unix/unix_errors.c
index 0facbae5..4fbcd821 100644
--- a/pr/src/md/unix/unix_errors.c
+++ b/pr/src/md/unix/unix_errors.c
@@ -283,6 +283,7 @@ void _MD_unix_readdir_error(int err)
PRErrorCode prError;
switch (err) {
+ case 0:
case ENOENT:
prError = PR_NO_MORE_FILES_ERROR;
break;
diff --git a/pr/src/pthreads/ptio.c b/pr/src/pthreads/ptio.c
index a4ffb6fe..1479846d 100644
--- a/pr/src/pthreads/ptio.c
+++ b/pr/src/pthreads/ptio.c
@@ -4299,6 +4299,7 @@ PR_IMPLEMENT(PRDirEntry*) PR_ReadDir(PRDir *dir, PRDirFlags flags)
for (;;)
{
+ errno = 0;
dp = readdir(dir->md.d);
if (NULL == dp)
{