summaryrefslogtreecommitdiff
path: root/src/scanner.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/scanner.c')
-rw-r--r--src/scanner.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/scanner.c b/src/scanner.c
index d20c714..ea35e3c 100644
--- a/src/scanner.c
+++ b/src/scanner.c
@@ -11,12 +11,14 @@
11#include <error.h> 11#include <error.h>
12 12
13dlinkedlist * scandirlist(const char * const dir, int (*selector)(const struct dirent *), int (*cmp)(const struct dirent **, const struct dirent **)) { 13dlinkedlist * scandirlist(const char * const dir, int (*selector)(const struct dirent *), int (*cmp)(const struct dirent **, const struct dirent **)) {
14 if(!dir || selector == NULL || cmp == NULL) ERRRET(EINVAL, NULL);
15
14 struct dirent **namelist = NULL; 16 struct dirent **namelist = NULL;
15 dlinkedlist *list = NULL; 17 dlinkedlist *list = NULL;
16 int numentries = -1; 18 int numentries = -1;
17 19
18 if((numentries = scandir(dir, &namelist, selector, cmp)) < 0) 20 if((numentries = scandir(dir, &namelist, selector, cmp)) < 0)
19 RETURNWERR(errno, NULL); 21 ERRRET(errno, NULL);
20 22
21 list = dlinkedlist_init(); 23 list = dlinkedlist_init();
22 for(int i = 0; i < numentries; i++) 24 for(int i = 0; i < numentries; i++)
@@ -26,7 +28,7 @@ dlinkedlist * scandirlist(const char * const dir, int (*selector)(const struct d
26 free(namelist[j]); 28 free(namelist[j]);
27 29
28 free(namelist); 30 free(namelist);
29 RETURNWERR(errno, NULL); 31 ERRRET(errno, NULL);
30 } 32 }
31 free(namelist); 33 free(namelist);
32 34