Skip to content

readdir_r is deprecated #70

@erikd

Description

@erikd

Building revision 40820da on Debian Testing I get:

cbits/HsUnix.c: In function ‘__hscore_readdir’:

cbits/HsUnix.c:64:3: error:
     warning: ‘readdir_r’ is deprecated [-Wdeprecated-declarations]
       res = readdir_r(dirPtr, p, pDirEnt);
       ^~~

In file included from include/HsUnix.h:71:0: error:
    0,
                     from cbits/HsUnix.c:9:

According to the man page:

This function is deprecated; use readdir(3) instead.

The readdir_r() function was invented as a reentrant version of readdir(3). It reads the next directory entry from the directory stream dirp, and returns it in the caller-allocated buffer pointed to by entry.

It is expected that a future version of POSIX.1 will make readdir_r() obsolete, and require that readdir() be thread-safe when concurrently employed on different directory streams.

Since the implementation already has #if HAVE_READDIR_R the fix mostly involves detecting whether readdir_r is deprecated or not and setting HAVE_READDIR_R appropriately.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions