From ca082f686fd2dc7ee6f0284421f6212d6d4acee8 Mon Sep 17 00:00:00 2001 From: Anton Kling Date: Thu, 11 Apr 2024 17:22:00 +0200 Subject: bug fixes --- userland/libc/dirent/scandir.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'userland/libc/dirent/scandir.c') 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 #include -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 *)); -- cgit v1.2.3