From 14c715a573ad55bd945b6438951e4b8931120173 Mon Sep 17 00:00:00 2001 From: Andreas Eversberg Date: Mon, 2 Oct 2017 18:10:11 +0200 Subject: [PATCH] Replaced depricated readdir_r --- gui/timeline.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/gui/timeline.c b/gui/timeline.c index 8fbd0c9..f5e5caf 100644 --- a/gui/timeline.c +++ b/gui/timeline.c @@ -34,9 +34,8 @@ static int cmpstringp(const void *p1, const void *p2) static dir_t *fetch_dir(const char *path) /* NOTE: if path is not empty, it must end with DIR_SEPERATOR */ { - int rc; DIR *dir; - struct dirent dirent, *result; + struct dirent *dirent; dir_t *head = NULL, *entry, **entryp = &head; int count = 0; dir_t **list; @@ -54,14 +53,12 @@ static dir_t *fetch_dir(const char *path) /* NOTE: if path is not empty, it must return NULL; } while (1) { - rc = readdir_r(dir, &dirent, &result); - if (rc < 0) + dirent = readdir(dir); + if (dirent == NULL) break; - if (result == NULL) - break; - if (result->d_type != DT_REG && result->d_type != DT_LNK) + if (dirent->d_type != DT_REG && dirent->d_type != DT_LNK) continue; - entry = calloc(1, sizeof(dir_t) + strlen(path) + strlen(result->d_name) + 1); + entry = calloc(1, sizeof(dir_t) + strlen(path) + strlen(dirent->d_name) + 1); if (!entry) { fprintf(stderr, "no memory"); return NULL; @@ -69,10 +66,10 @@ static dir_t *fetch_dir(const char *path) /* NOTE: if path is not empty, it must *entryp = entry; entryp = &entry->next; #ifdef DEBUG_FILENAME - printf("Fetching entry: path='%s' filename='%s'\n", path, result->d_name); + printf("Fetching entry: path='%s' filename='%s'\n", path, dirent->d_name); #endif strcpy(entry->name, path); - strcat(entry->name, result->d_name); + strcat(entry->name, dirent->d_name); count++; } closedir(dir); -- 2.13.6