summaryrefslogtreecommitdiff
path: root/userland/libc/dirent
diff options
context:
space:
mode:
authorAnton Kling <anton@kling.gg>2024-04-11 17:22:00 +0200
committerAnton Kling <anton@kling.gg>2024-04-11 17:23:39 +0200
commitca082f686fd2dc7ee6f0284421f6212d6d4acee8 (patch)
tree493b1047661174816f0d1d300952e40e2846b24b /userland/libc/dirent
parente25a47fcc4db09ab9b845a691297da67243e6049 (diff)
bug fixes
Diffstat (limited to 'userland/libc/dirent')
-rw-r--r--userland/libc/dirent/scandir.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/userland/libc/dirent/scandir.c b/userland/libc/dirent/scandir.c
index 945bc1f..564cbc8 100644
--- a/userland/libc/dirent/scandir.c
+++ b/userland/libc/dirent/scandir.c
@@ -2,11 +2,6 @@
#include <stdlib.h>
#include <string.h>
-int nop_sel(const struct dirent *unused) {
- (void)unused;
- return 1;
-}
-
int nop_compar(const struct dirent **d1, const struct dirent **d2) {
*d2 = *d1;
return 0;
@@ -15,9 +10,6 @@ int nop_compar(const struct dirent **d1, const struct dirent **d2) {
int scandir(const char *dir, struct dirent ***namelist,
int (*sel)(const struct dirent *),
int (*compar)(const struct dirent **, const struct dirent **)) {
- if (!sel)
- sel = nop_sel;
-
if (!compar)
compar = nop_compar;
@@ -28,8 +20,11 @@ int scandir(const char *dir, struct dirent ***namelist,
struct dirent *e;
int rc = 0;
for (; (e = readdir(d));) {
- if (!sel(e))
- continue;
+ if (sel) {
+ if (!sel(e)) {
+ continue;
+ }
+ }
struct dirent *p = malloc(sizeof(struct dirent));
memcpy(p, e, sizeof(struct dirent));
list = realloc(list, (rc + 1) * sizeof(struct dirent *));