Branch: Tag:

2017-02-26

2017-02-26 10:45:38 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Stdio: Avoid using readdir_r(3C).

readdir_r() has been marked as deprecated in current glibc, and
is redundant in all modern libc's, where readdir(3C) is thread
safe as long as the same DIR/dirfd is not used in several threads.

5572:    {    INT_TYPE fd;    char *ep; -  struct dirent ent, *res; +  struct dirent *res;    /* solaris, linux, cygwin, darwin, netbsd et.al. */    res = NULL; -  while( UNLIKELY(readdir_r( tmp, &ent, &res )) -  && UNLIKELY(errno==EINTR)) +  while( UNLIKELY(!(res = readdir(tmp))) && UNLIKELY(errno==EINTR))    ;    if( !res )    break;