* [PATCH] Deprecate readdir_r, readdir64_r [BZ #19056]
@ 2016-02-08 16:37 Florian Weimer
2016-02-20 8:19 ` Mike Frysinger
2016-02-22 13:58 ` [PATCH] Add missing include to posix/tst-dir.c Tulio Magno Quites Machado Filho
0 siblings, 2 replies; 7+ messages in thread
From: Florian Weimer @ 2016-02-08 16:37 UTC (permalink / raw)
To: GNU C Library
[-- Attachment #1: Type: text/plain, Size: 106 bytes --]
This patch adds __attribute__ ((deprecated)) to <dirent.h>.
(This is 2.24 material, of course.)
Florian
[-- Attachment #2: 0001-Deprecate-readdir_r-BZ-19056.patch --]
[-- Type: text/x-patch, Size: 4651 bytes --]
2016-02-08 Florian Weimer <fweimer@redhat.com>
[BZ #19056]
* dirent/dirent.h (readdir_r, readdir64_r): Mark as deprecated.
* manual/filesys.texi (Reading/Closing Directory): Mention
deprecaion.
* posix/tst-dir.c (main): Disable deprecation warning in test.
diff --git a/NEWS b/NEWS
index 93c09be..56b8f44 100644
--- a/NEWS
+++ b/NEWS
@@ -73,6 +73,9 @@ Version 2.23
C Library is GCC 4.7. Older GCC versions, and non-GNU compilers, can
still be used to compile programs using the GNU C Library.
+* The readdir_r and readdir64_r functions are deprecated. It is recommended
+ to use readdir and readdir64 instead.
+
Security related changes:
* The nan, nanf and nanl functions no longer have unbounded stack usage
diff --git a/dirent/dirent.h b/dirent/dirent.h
index 9a4b6bf..e6c36b1 100644
--- a/dirent/dirent.h
+++ b/dirent/dirent.h
@@ -183,14 +183,15 @@ extern struct dirent64 *readdir64 (DIR *__dirp) __nonnull ((1));
extern int readdir_r (DIR *__restrict __dirp,
struct dirent *__restrict __entry,
struct dirent **__restrict __result)
- __nonnull ((1, 2, 3));
+ __nonnull ((1, 2, 3)) __attribute_deprecated__;
# else
# ifdef __REDIRECT
extern int __REDIRECT (readdir_r,
(DIR *__restrict __dirp,
struct dirent *__restrict __entry,
struct dirent **__restrict __result),
- readdir64_r) __nonnull ((1, 2, 3));
+ readdir64_r)
+ __nonnull ((1, 2, 3)) __attribute_deprecated__;
# else
# define readdir_r readdir64_r
# endif
@@ -200,7 +201,7 @@ extern int __REDIRECT (readdir_r,
extern int readdir64_r (DIR *__restrict __dirp,
struct dirent64 *__restrict __entry,
struct dirent64 **__restrict __result)
- __nonnull ((1, 2, 3));
+ __nonnull ((1, 2, 3)) __attribute_deprecated__;
# endif
#endif /* POSIX or misc */
diff --git a/manual/filesys.texi b/manual/filesys.texi
index 972e106..b323664 100644
--- a/manual/filesys.texi
+++ b/manual/filesys.texi
@@ -525,8 +525,9 @@ locking. Like @code{readdir} it returns the next entry from the
directory. To prevent conflicts between simultaneously running
threads the result is stored inside the @var{entry} object.
-@strong{Portability Note:} It is recommended to use @code{readdir}
-instead of @code{readdir_r} for the following reasons:
+@strong{Portability Note:} @code{readdir_r} is deprecated. It is
+recommended to use @code{readdir} instead of @code{readdir_r} for the
+following reasons:
@itemize @bullet
@item
@@ -604,10 +605,10 @@ In all other aspects this function is equivalent to @code{readdir}.
@comment LFS
@deftypefun int readdir64_r (DIR *@var{dirstream}, struct dirent64 *@var{entry}, struct dirent64 **@var{result})
@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}}
-The @code{readdir64_r} function is equivalent to the @code{readdir_r}
-function except that it takes parameters of base type @code{struct
-dirent64} instead of @code{struct dirent} in the second and third
-position. The same precautions mentioned in the documentation of
+The deprecated @code{readdir64_r} function is equivalent to the
+@code{readdir_r} function except that it takes parameters of base type
+@code{struct dirent64} instead of @code{struct dirent} in the second and
+third position. The same precautions mentioned in the documentation of
@code{readdir_r} also apply here.
@end deftypefun
diff --git a/posix/tst-dir.c b/posix/tst-dir.c
index 8897f8e..d0e4878 100644
--- a/posix/tst-dir.c
+++ b/posix/tst-dir.c
@@ -319,6 +319,10 @@ main (int argc, char *argv[])
exit (1);
}
+ /* The test below covers the deprecated readdir64_r function. */
+ DIAG_PUSH_NEEDS_COMMENT;
+ DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wdeprecated-declarations");
+
/* Try to find the new directory. */
rewinddir (dir1);
while (readdir64_r (dir1, &direntbuf.d, &d) == 0 && d != NULL)
@@ -351,6 +355,8 @@ main (int argc, char *argv[])
}
}
+ DIAG_POP_NEEDS_COMMENT;
+
if (d == NULL)
{
printf ("haven't found new directory \"%s\"\n", buf);
@@ -439,6 +445,10 @@ main (int argc, char *argv[])
result = 1;
}
+ /* The test below covers the deprecated readdir64_r function. */
+ DIAG_PUSH_NEEDS_COMMENT;
+ DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wdeprecated-declarations");
+
/* We now should have a directory and a file in the new directory. */
rewinddir (dir2);
while (readdir64_r (dir2, &direntbuf.d, &d) == 0 && d != NULL)
@@ -492,6 +502,8 @@ main (int argc, char *argv[])
}
}
+ DIAG_POP_NEEDS_COMMENT;
+
if (stat64 ("does-not-exist", &st1) >= 0)
{
puts ("stat for unexisting file did not fail");
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Deprecate readdir_r, readdir64_r [BZ #19056]
2016-02-08 16:37 [PATCH] Deprecate readdir_r, readdir64_r [BZ #19056] Florian Weimer
@ 2016-02-20 8:19 ` Mike Frysinger
2016-02-22 13:58 ` [PATCH] Add missing include to posix/tst-dir.c Tulio Magno Quites Machado Filho
1 sibling, 0 replies; 7+ messages in thread
From: Mike Frysinger @ 2016-02-20 8:19 UTC (permalink / raw)
To: Florian Weimer; +Cc: GNU C Library
[-- Attachment #1: Type: text/plain, Size: 116 bytes --]
On 08 Feb 2016 17:37, Florian Weimer wrote:
> This patch adds __attribute__ ((deprecated)) to <dirent.h>.
OK
-mike
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] Add missing include to posix/tst-dir.c
2016-02-08 16:37 [PATCH] Deprecate readdir_r, readdir64_r [BZ #19056] Florian Weimer
2016-02-20 8:19 ` Mike Frysinger
@ 2016-02-22 13:58 ` Tulio Magno Quites Machado Filho
2016-02-22 13:59 ` Florian Weimer
1 sibling, 1 reply; 7+ messages in thread
From: Tulio Magno Quites Machado Filho @ 2016-02-22 13:58 UTC (permalink / raw)
To: fweimer; +Cc: libc-alpha
A recent change to posix/tst-dir.c started to use macros from
libc-internal.h but didn't include it, causing build issues.
2016-02-22 Tulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>
* posix/tst-dir.c: Include libc-internal.h.
---
posix/tst-dir.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/posix/tst-dir.c b/posix/tst-dir.c
index d0e4878..4b15f34 100644
--- a/posix/tst-dir.c
+++ b/posix/tst-dir.c
@@ -26,6 +26,7 @@
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
+#include <libc-internal.h>
/* We expect four arguments:
--
2.1.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Add missing include to posix/tst-dir.c
2016-02-22 13:58 ` [PATCH] Add missing include to posix/tst-dir.c Tulio Magno Quites Machado Filho
@ 2016-02-22 13:59 ` Florian Weimer
2016-02-22 14:31 ` Tulio Magno Quites Machado Filho
0 siblings, 1 reply; 7+ messages in thread
From: Florian Weimer @ 2016-02-22 13:59 UTC (permalink / raw)
To: Tulio Magno Quites Machado Filho; +Cc: libc-alpha
* Tulio Magno Quites Machado Filho:
> A recent change to posix/tst-dir.c started to use macros from
> libc-internal.h but didn't include it, causing build issues.
>
> 2016-02-22 Tulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>
>
> * posix/tst-dir.c: Include libc-internal.h.
I have never seen a need to include <libc-internal.h> like this
before. How are you building the tests that you need this?
Thanks,
Florian
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Add missing include to posix/tst-dir.c
2016-02-22 13:59 ` Florian Weimer
@ 2016-02-22 14:31 ` Tulio Magno Quites Machado Filho
2016-02-22 15:23 ` Florian Weimer
0 siblings, 1 reply; 7+ messages in thread
From: Tulio Magno Quites Machado Filho @ 2016-02-22 14:31 UTC (permalink / raw)
To: Florian Weimer; +Cc: libc-alpha
Florian Weimer <fw@deneb.enyo.de> writes:
> * Tulio Magno Quites Machado Filho:
>
>> A recent change to posix/tst-dir.c started to use macros from
>> libc-internal.h but didn't include it, causing build issues.
>>
>> 2016-02-22 Tulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>
>>
>> * posix/tst-dir.c: Include libc-internal.h.
>
> I have never seen a need to include <libc-internal.h> like this
> before. How are you building the tests that you need this?
There is nothing special:
configure --prefix=/usr --with-cpu=power8 --enable-add-ons
make
make -k check
I'm using GCC 4.8.4.
It seems we already have some testcases doing that:
$ find . -type f \( -name 'test-*' -o -name 'tst-*' -o -name 'bug*' \) \
| xargs grep -n libc-internal.h
./stdio-common/tst-printfsz.c:5:#include <libc-internal.h>
./stdio-common/tst-unlockedio.c:23:#include <libc-internal.h>
./stdio-common/test-vfprintf.c:28:#include <libc-internal.h>
./stdio-common/tst-sprintf.c:5:#include <libc-internal.h>
./stdio-common/bug21.c:2:#include <libc-internal.h>
./stdio-common/tst-printf.c:29:#include <libc-internal.h>
./string/tst-endian.c:6:#include <libc-internal.h>
./misc/tst-error1.c:6:#include <libc-internal.h>
--
Tulio Magno
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Add missing include to posix/tst-dir.c
2016-02-22 14:31 ` Tulio Magno Quites Machado Filho
@ 2016-02-22 15:23 ` Florian Weimer
2016-02-22 16:40 ` Tulio Magno Quites Machado Filho
0 siblings, 1 reply; 7+ messages in thread
From: Florian Weimer @ 2016-02-22 15:23 UTC (permalink / raw)
To: Tulio Magno Quites Machado Filho; +Cc: libc-alpha
* Tulio Magno Quites Machado Filho:
> Florian Weimer <fw@deneb.enyo.de> writes:
>
>> * Tulio Magno Quites Machado Filho:
>>
>>> A recent change to posix/tst-dir.c started to use macros from
>>> libc-internal.h but didn't include it, causing build issues.
>>>
>>> 2016-02-22 Tulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>
>>>
>>> * posix/tst-dir.c: Include libc-internal.h.
>>
>> I have never seen a need to include <libc-internal.h> like this
>> before. How are you building the tests that you need this?
>
> There is nothing special:
> configure --prefix=/usr --with-cpu=power8 --enable-add-ons
> make
> make -k check
>
> I'm using GCC 4.8.4.
Thanks, found the difference, it's due to the #includes in
sysdeps/i386/nptl/tls.h and sysdeps/x86_64/nptl/tls.h. Perhaps we can
get rid of that to avoid future such breakage.
Patch is fine.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Add missing include to posix/tst-dir.c
2016-02-22 15:23 ` Florian Weimer
@ 2016-02-22 16:40 ` Tulio Magno Quites Machado Filho
0 siblings, 0 replies; 7+ messages in thread
From: Tulio Magno Quites Machado Filho @ 2016-02-22 16:40 UTC (permalink / raw)
To: Florian Weimer, stli; +Cc: libc-alpha
Florian Weimer <fw@deneb.enyo.de> writes:
> Thanks, found the difference, it's due to the #includes in
> sysdeps/i386/nptl/tls.h and sysdeps/x86_64/nptl/tls.h. Perhaps we can
> get rid of that to avoid future such breakage.
>
> Patch is fine.
I just noticed Stefan sent another patch before me:
http://patchwork.sourceware.org/patch/10980/
Stefan, feel free to push it. ;-)
--
Tulio Magno
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2016-02-22 16:40 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-08 16:37 [PATCH] Deprecate readdir_r, readdir64_r [BZ #19056] Florian Weimer
2016-02-20 8:19 ` Mike Frysinger
2016-02-22 13:58 ` [PATCH] Add missing include to posix/tst-dir.c Tulio Magno Quites Machado Filho
2016-02-22 13:59 ` Florian Weimer
2016-02-22 14:31 ` Tulio Magno Quites Machado Filho
2016-02-22 15:23 ` Florian Weimer
2016-02-22 16:40 ` Tulio Magno Quites Machado Filho
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).