[scan] readdir_r deprecated, use readdir instead

This commit is contained in:
ejurgensen 2016-11-19 23:50:14 +01:00
parent bdd6bab982
commit 94a55d9fc9
1 changed files with 8 additions and 8 deletions

View File

@ -929,7 +929,6 @@ static void
process_directory(char *path, int parent_id, int flags) process_directory(char *path, int parent_id, int flags)
{ {
DIR *dirp; DIR *dirp;
struct dirent buf;
struct dirent *de; struct dirent *de;
char entry[PATH_MAX]; char entry[PATH_MAX];
char *deref; char *deref;
@ -976,24 +975,25 @@ process_directory(char *path, int parent_id, int flags)
if (scan_exit) if (scan_exit)
break; break;
ret = readdir_r(dirp, &buf, &de); errno = 0;
if (ret != 0) de = readdir(dirp);
if (errno)
{ {
DPRINTF(E_LOG, L_SCAN, "readdir_r error in %s: %s\n", path, strerror(errno)); DPRINTF(E_LOG, L_SCAN, "readdir error in %s: %s\n", path, strerror(errno));
break; break;
} }
if (de == NULL) if (!de)
break; break;
if (buf.d_name[0] == '.') if (de->d_name[0] == '.')
continue; continue;
ret = snprintf(entry, sizeof(entry), "%s/%s", path, buf.d_name); ret = snprintf(entry, sizeof(entry), "%s/%s", path, de->d_name);
if ((ret < 0) || (ret >= sizeof(entry))) if ((ret < 0) || (ret >= sizeof(entry)))
{ {
DPRINTF(E_LOG, L_SCAN, "Skipping %s/%s, PATH_MAX exceeded\n", path, buf.d_name); DPRINTF(E_LOG, L_SCAN, "Skipping %s/%s, PATH_MAX exceeded\n", path, de->d_name);
continue; continue;
} }