apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jor...@apache.org
Subject svn commit: r265684 - /apr/apr/trunk/file_io/unix/dir.c
Date Thu, 01 Sep 2005 09:39:14 GMT
Author: jorton
Date: Thu Sep  1 02:39:11 2005
New Revision: 265684

URL: http://svn.apache.org/viewcvs?rev=265684&view=rev
Log:
* file_io/unix/dir.c (apr_dir_open): Fix error handling; don't assume
that apr_pcalloc can't change errno.  Remove a redundant cast to 
void *.

Modified:
    apr/apr/trunk/file_io/unix/dir.c

Modified: apr/apr/trunk/file_io/unix/dir.c
URL: http://svn.apache.org/viewcvs/apr/apr/trunk/file_io/unix/dir.c?rev=265684&r1=265683&r2=265684&view=diff
==============================================================================
--- apr/apr/trunk/file_io/unix/dir.c (original)
+++ apr/apr/trunk/file_io/unix/dir.c Thu Sep  1 02:39:11 2005
@@ -79,22 +79,22 @@
     apr_size_t dirent_size = 
         sizeof(*(*new)->entry) +
         (sizeof((*new)->entry->d_name) > 1 ? 0 : 255);
+    DIR *dir = opendir(dirname);
+
+    if (!dir) {
+        return errno;
+    }
 
     (*new) = (apr_dir_t *)apr_palloc(pool, sizeof(apr_dir_t));
 
     (*new)->pool = pool;
     (*new)->dirname = apr_pstrdup(pool, dirname);
-    (*new)->dirstruct = opendir(dirname);
+    (*new)->dirstruct = dir;
     (*new)->entry = apr_pcalloc(pool, dirent_size);
 
-    if ((*new)->dirstruct == NULL) {
-        return errno;
-    }    
-    else {
-        apr_pool_cleanup_register((*new)->pool, (void *)(*new), dir_cleanup,
-	                          apr_pool_cleanup_null);
-        return APR_SUCCESS;
-    }
+    apr_pool_cleanup_register((*new)->pool, *new, dir_cleanup,
+                              apr_pool_cleanup_null);
+    return APR_SUCCESS;
 }
 
 apr_status_t apr_dir_close(apr_dir_t *thedir)



Mime
View raw message