* [PATCH] libdrm: Use readdir instead of readdir_r to avoid build warnings
@ 2018-03-19 13:47 John Stultz
2018-03-19 14:11 ` Emil Velikov
2018-03-19 14:41 ` Eric Engestrom
0 siblings, 2 replies; 4+ messages in thread
From: John Stultz @ 2018-03-19 13:47 UTC (permalink / raw)
To: dri-devel; +Cc: Robert Foss, Stefan Schake
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) {
^
Thus, this patch replaces readdir_r with readdir.
Cc: Robert Foss <robert.foss@collabora.com>
Cc: Rob Herring <robh@kernel.org>
Cc: Stefan Schake <stschake@gmail.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
---
xf86drm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/xf86drm.c b/xf86drm.c
index 344326d..b9058c2 100644
--- a/xf86drm.c
+++ b/xf86drm.c
@@ -2858,7 +2858,7 @@ static char *drmGetMinorNameForFD(int fd, int type)
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",
ent->d_name);
--
2.7.4
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] libdrm: Use readdir instead of readdir_r to avoid build warnings
2018-03-19 13:47 [PATCH] libdrm: Use readdir instead of readdir_r to avoid build warnings John Stultz
@ 2018-03-19 14:11 ` Emil Velikov
2018-03-19 14:41 ` Eric Engestrom
1 sibling, 0 replies; 4+ messages in thread
From: Emil Velikov @ 2018-03-19 14:11 UTC (permalink / raw)
To: John Stultz; +Cc: Robert Foss, dri-devel, Stefan Schake
On 19 March 2018 at 13:47, John Stultz <john.stultz@linaro.org> wrote:
> 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) {
> ^
>
> Thus, this patch replaces readdir_r with readdir.
>
When C runtime suggests new behaviour before the manual/spec is updated... sigh.
readdir(3)
It is expected that a future version of POSIX.1 will require that
readdir() be thread-safe when concurrently employed on different
directory streams
readdir_r(3)
It is expected that a future version of POSIX.1 will make readdir_r()
obsolete, and require that readdir(3) be thread-safe when concurrently
employed on different directory streams.
Regardless, patch is
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
-Emil
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] libdrm: Use readdir instead of readdir_r to avoid build warnings
2018-03-19 13:47 [PATCH] libdrm: Use readdir instead of readdir_r to avoid build warnings John Stultz
2018-03-19 14:11 ` Emil Velikov
@ 2018-03-19 14:41 ` Eric Engestrom
2018-03-20 17:54 ` Emil Velikov
1 sibling, 1 reply; 4+ messages in thread
From: Eric Engestrom @ 2018-03-19 14:41 UTC (permalink / raw)
To: John Stultz; +Cc: Robert Foss, dri-devel, Stefan Schake
On Monday, 2018-03-19 06:47:32 -0700, John Stultz wrote:
> 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) {
> ^
>
> Thus, this patch replaces readdir_r with readdir.
>
> Cc: Robert Foss <robert.foss@collabora.com>
> Cc: Rob Herring <robh@kernel.org>
> Cc: Stefan Schake <stschake@gmail.com>
> Signed-off-by: John Stultz <john.stultz@linaro.org>
> ---
> xf86drm.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/xf86drm.c b/xf86drm.c
> index 344326d..b9058c2 100644
> --- a/xf86drm.c
> +++ b/xf86drm.c
> @@ -2858,7 +2858,7 @@ static char *drmGetMinorNameForFD(int fd, int type)
> if (pent == NULL)
> goto out_close_dir;
>
> - while (readdir_r(sysdir, pent, &ent) == 0 && ent != NULL) {
> + while ((ent = readdir(sysdir))) {
I've had the same patch locally for some time, and while this line is
correct, it's missing other changes to clean up unnecessary code around.
I don't have the change on this machine, I'll look at it tonight, but if
you beat me to it, from memory there's a malloc()+free() around, and
a couple unused variables now that should be removed at the start of
the scope.
> if (strncmp(ent->d_name, name, len) == 0) {
> snprintf(dev_name, sizeof(dev_name), DRM_DIR_NAME "/%s",
> ent->d_name);
> --
> 2.7.4
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] libdrm: Use readdir instead of readdir_r to avoid build warnings
2018-03-19 14:41 ` Eric Engestrom
@ 2018-03-20 17:54 ` Emil Velikov
0 siblings, 0 replies; 4+ messages in thread
From: Emil Velikov @ 2018-03-20 17:54 UTC (permalink / raw)
To: Eric Engestrom; +Cc: Robert Foss, dri-devel, Stefan Schake
On 19 March 2018 at 14:41, Eric Engestrom <eric.engestrom@imgtec.com> wrote:
> On Monday, 2018-03-19 06:47:32 -0700, John Stultz wrote:
>> 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) {
>> ^
>>
>> Thus, this patch replaces readdir_r with readdir.
>>
>> Cc: Robert Foss <robert.foss@collabora.com>
>> Cc: Rob Herring <robh@kernel.org>
>> Cc: Stefan Schake <stschake@gmail.com>
>> Signed-off-by: John Stultz <john.stultz@linaro.org>
>> ---
>> xf86drm.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/xf86drm.c b/xf86drm.c
>> index 344326d..b9058c2 100644
>> --- a/xf86drm.c
>> +++ b/xf86drm.c
>> @@ -2858,7 +2858,7 @@ static char *drmGetMinorNameForFD(int fd, int type)
>> if (pent == NULL)
>> goto out_close_dir;
>>
>> - while (readdir_r(sysdir, pent, &ent) == 0 && ent != NULL) {
>> + while ((ent = readdir(sysdir))) {
>
> I've had the same patch locally for some time, and while this line is
> correct, it's missing other changes to clean up unnecessary code around.
>
> I don't have the change on this machine, I'll look at it tonight, but if
> you beat me to it, from memory there's a malloc()+free() around, and
> a couple unused variables now that should be removed at the start of
> the scope.
>
Right - updated patch should be in your inbox.
-Emil
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-03-20 17:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-19 13:47 [PATCH] libdrm: Use readdir instead of readdir_r to avoid build warnings John Stultz
2018-03-19 14:11 ` Emil Velikov
2018-03-19 14:41 ` Eric Engestrom
2018-03-20 17:54 ` Emil Velikov
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.