aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Stultz2018-03-20 12:48:23 -0500
committerEmil Velikov2018-03-22 11:47:47 -0500
commitbb45ce4e3ac751315bfd7fbfd9e1425bf515ec0d (patch)
tree7a75236f2ff7538a2b1aad132cc1eee2561cc2b2 /xf86drm.c
parent32ee9c0e0566ee6642c3df02315a2595105c0c87 (diff)
downloadexternal-libgbm-bb45ce4e3ac751315bfd7fbfd9e1425bf515ec0d.tar.gz
external-libgbm-bb45ce4e3ac751315bfd7fbfd9e1425bf515ec0d.tar.xz
external-libgbm-bb45ce4e3ac751315bfd7fbfd9e1425bf515ec0d.zip
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. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102031 Cc: Robert Foss <robert.foss@collabora.com> Cc: Rob Herring <robh@kernel.org> Cc: Stefan Schake <stschake@gmail.com> Cc: John Stultz <john.stultz@linaro.org> Signed-off-by: John Stultz <john.stultz@linaro.org> Reviewed-by: Emil Velikov <emil.velikov@collabora.com> [Emil Velikov: remove unused variables, Eric] Signed-off-by: Emil Velikov <emil.velikov@collabora.com> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Diffstat (limited to 'xf86drm.c')
-rw-r--r--xf86drm.c22
1 files changed, 3 insertions, 19 deletions
diff --git a/xf86drm.c b/xf86drm.c
index 689e8fe9..3a9d0ed2 100644
--- a/xf86drm.c
+++ b/xf86drm.c
@@ -2819,12 +2819,11 @@ static char *drmGetMinorNameForFD(int fd, int type)
2819{ 2819{
2820#ifdef __linux__ 2820#ifdef __linux__
2821 DIR *sysdir; 2821 DIR *sysdir;
2822 struct dirent *pent, *ent; 2822 struct dirent *ent;
2823 struct stat sbuf; 2823 struct stat sbuf;
2824 const char *name = drmGetMinorName(type); 2824 const char *name = drmGetMinorName(type);
2825 int len; 2825 int len;
2826 char dev_name[64], buf[64]; 2826 char dev_name[64], buf[64];
2827 long name_max;
2828 int maj, min; 2827 int maj, min;
2829 2828
2830 if (!name) 2829 if (!name)
@@ -2847,30 +2846,16 @@ static char *drmGetMinorNameForFD(int fd, int type)
2847 if (!sysdir) 2846 if (!sysdir)
2848 return NULL; 2847 return NULL;
2849 2848
2850 name_max = fpathconf(dirfd(sysdir), _PC_NAME_MAX); 2849 while ((ent = readdir(sysdir))) {
2851 if (name_max == -1)
2852 goto out_close_dir;
2853
2854 pent = malloc(offsetof(struct dirent, d_name) + name_max + 1);
2855 if (pent == NULL)
2856 goto out_close_dir;
2857
2858 while (readdir_r(sysdir, pent, &ent) == 0 && ent != NULL) {
2859 if (strncmp(ent->d_name, name, len) == 0) { 2850 if (strncmp(ent->d_name, name, len) == 0) {
2860 snprintf(dev_name, sizeof(dev_name), DRM_DIR_NAME "/%s", 2851 snprintf(dev_name, sizeof(dev_name), DRM_DIR_NAME "/%s",
2861 ent->d_name); 2852 ent->d_name);
2862 2853
2863 free(pent);
2864 closedir(sysdir); 2854 closedir(sysdir);
2865
2866 return strdup(dev_name); 2855 return strdup(dev_name);
2867 } 2856 }
2868 } 2857 }
2869 2858 return NULL;
2870 free(pent);
2871
2872out_close_dir:
2873 closedir(sysdir);
2874#else 2859#else
2875 struct stat sbuf; 2860 struct stat sbuf;
2876 char buf[PATH_MAX + 1]; 2861 char buf[PATH_MAX + 1];
@@ -2911,7 +2896,6 @@ out_close_dir:
2911 2896
2912 return strdup(buf); 2897 return strdup(buf);
2913#endif 2898#endif
2914 return NULL;
2915} 2899}
2916 2900
2917char *drmGetPrimaryDeviceNameFromFd(int fd) 2901char *drmGetPrimaryDeviceNameFromFd(int fd)