Fix for bug #7390
| From: | Jani Taskinen | Date: | Sun, 26 Nov 2000 02:31:12 +0000 |
| Subject: | Fix for bug #7390 | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-39132@lists.php.net to get a copy of this message | ||
This fixes the usage of old readdir_r().
errno is 0 if readdir_r() is succesful.
---8<------------------------------------------------------------
RETURN VALUES
Upon successful completion, readdir() and readdir_r() return
a pointer to an object of type struct dirent. When an error
is encountered, a null pointer is returned and errno is set
to indicate the error. When the end of the directory is
encountered, a null pointer is returned and errno is not
changed. The POSIX readdir_r() returns 0 if successful or
an error number to indicate failure.
---------8<------------------------------------------------------
Please check this out and if nobody objects, I will commit this
next week.
--Jani
Index: reentrancy.c
===================================================================
RCS file: /repository/php4/main/reentrancy.c,v
retrieving revision 1.23
diff -u -r1.23 reentrancy.c
--- reentrancy.c 2000/06/12 14:11:39 1.23
+++ reentrancy.c 2000/11/26 02:22:20
@@ -104,15 +104,15 @@
errno = 0;
ret = readdir_r(dirp, entry);
-
- if (ret == 0)
- *result = entry;
- else if (errno == 0) {
+
+ if (!ret || errno != 0) {
*result = NULL;
- ret = 0;
+ } else {
+ *result = entry;
}
+
+ return errno;
- return ret;
#else
struct dirent *ptr;
int ret = 0;