summaryrefslogtreecommitdiff
path: root/libc/misc/dirent/scandir.c
diff options
context:
space:
mode:
authorBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2008-10-18 12:48:09 +0000
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2008-10-18 12:48:09 +0000
commit5016062735e34d4474e9c0305b51ebae90ab7a4a (patch)
tree525b2ffc888996060be10c579f2d0056275e3206 /libc/misc/dirent/scandir.c
parentdce2384770a6e791312cb3330233d733ed1b0949 (diff)
- sync fix for scandir errno handling to scandir64 (r23600)
Thanks to Peter S. Mazinger for mentioning this.
Diffstat (limited to 'libc/misc/dirent/scandir.c')
-rw-r--r--libc/misc/dirent/scandir.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/libc/misc/dirent/scandir.c b/libc/misc/dirent/scandir.c
index ad997b121..9b0f7385a 100644
--- a/libc/misc/dirent/scandir.c
+++ b/libc/misc/dirent/scandir.c
@@ -13,10 +13,10 @@
#include "dirstream.h"
/* Experimentally off - libc_hidden_proto(memcpy) */
-libc_hidden_proto(readdir)
libc_hidden_proto(opendir)
libc_hidden_proto(closedir)
libc_hidden_proto(qsort)
+libc_hidden_proto(readdir)
int scandir(const char *dir, struct dirent ***namelist,
int (*selector) (const struct dirent *),
@@ -40,14 +40,12 @@ int scandir(const char *dir, struct dirent ***namelist,
if (! use_it)
{
- use_it = (*selector) (current);
- /*
- * The selector function might have changed errno.
- * It was zero before and it need to be again to make
- * the latter tests work.
- */
- if (! use_it)
- __set_errno (0);
+ use_it = (*selector) (current);
+ /* The selector function might have changed errno.
+ * It was zero before and it need to be again to make
+ * the latter tests work. */
+ if (! use_it)
+ __set_errno (0);
}
if (use_it)
{
@@ -64,20 +62,21 @@ int scandir(const char *dir, struct dirent ***namelist,
names_size = 10;
else
names_size *= 2;
- new = (struct dirent **) realloc (names, names_size * sizeof (struct dirent *));
+ new = (struct dirent **) realloc (names,
+ names_size * sizeof (struct dirent *));
if (new == NULL)
break;
names = new;
}
- dsize = &current->d_name[_D_ALLOC_NAMLEN (current)] - (char *) current;
+ dsize = &current->d_name[_D_ALLOC_NAMLEN(current)] - (char*)current;
vnew = (struct dirent *) malloc (dsize);
if (vnew == NULL)
break;
names[pos++] = (struct dirent *) memcpy (vnew, current, dsize);
}
- }
+ }
if (unlikely(errno != 0))
{