Commit bb45ce4e authored by John Stultz's avatar John Stultz Committed by Emil Velikov
Browse files

libdrm: Use readdir instead of readdir_r to avoid build warnings

Building libdrm under AOSP, we see the following build warning:
external/libdrm/xf86drm.c:2861:12: warning: 'readdir_r' is deprecated: readdir_r is deprecated; use readdir instead [-Wdeprecated-declarations]
    while (readdir_r(sysdir, pent, &ent) == 0 && ent != NULL) {

Building on Linux with glibc produces the same warning.
Thus, this patch replaces readdir_r with readdir.


Cc: Robert Foss <>
Cc: Rob Herring <>
Cc: Stefan Schake <>
Cc: John Stultz <>
Signed-off-by: John Stultz's avatarJohn Stultz <>
Reviewed-by: Emil Velikov's avatarEmil Velikov <>
[Emil Velikov: remove unused variables, Eric]
Signed-off-by: Emil Velikov's avatarEmil Velikov <>
Reviewed-by: Eric Engestrom's avatarEric Engestrom <>
parent 32ee9c0e
......@@ -2819,12 +2819,11 @@ static char *drmGetMinorNameForFD(int fd, int type)
#ifdef __linux__
DIR *sysdir;
struct dirent *pent, *ent;
struct dirent *ent;
struct stat sbuf;
const char *name = drmGetMinorName(type);
int len;
char dev_name[64], buf[64];
long name_max;
int maj, min;
if (!name)
......@@ -2847,30 +2846,16 @@ static char *drmGetMinorNameForFD(int fd, int type)
if (!sysdir)
return NULL;
name_max = fpathconf(dirfd(sysdir), _PC_NAME_MAX);
if (name_max == -1)
goto out_close_dir;
pent = malloc(offsetof(struct dirent, d_name) + name_max + 1);
if (pent == NULL)
goto out_close_dir;
while (readdir_r(sysdir, pent, &ent) == 0 && ent != NULL) {
while ((ent = readdir(sysdir))) {
if (strncmp(ent->d_name, name, len) == 0) {
snprintf(dev_name, sizeof(dev_name), DRM_DIR_NAME "/%s",
return strdup(dev_name);
return NULL;
struct stat sbuf;
char buf[PATH_MAX + 1];
......@@ -2911,7 +2896,6 @@ out_close_dir:
return strdup(buf);
return NULL;
char *drmGetPrimaryDeviceNameFromFd(int fd)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment