Replaced depricated readdir_r
authorAndreas Eversberg <jolly@eversberg.eu>
Mon, 2 Oct 2017 16:10:11 +0000 (18:10 +0200)
committerAndreas Eversberg <jolly@eversberg.eu>
Mon, 2 Oct 2017 16:11:57 +0000 (18:11 +0200)
gui/timeline.c

index 8fbd0c9..f5e5caf 100644 (file)
@@ -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);