aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDag-Erling Smørgrav <des@FreeBSD.org>2025-08-01 23:11:31 +0000
committerDag-Erling Smørgrav <des@FreeBSD.org>2025-08-01 23:11:56 +0000
commit2bd157bc732a1939cb71314e48de6118b91e0ad0 (patch)
treebd528e2d37edcbb7dbc692e8c2cbbb7183741567
parent65bae451c23b8d61b2433259d8e707250660eeff (diff)
libc: Deprecate readdir_r()
This function was never safe to use. We marked it deprecated in the manual page in 2016, and it is marked obsolete in POSIX 2024. Add a linker warning and annotate the prototype. Sponsored by: Klara, Inc. Reviewed by: imp, markj Differential Revision: https://reviews.freebsd.org/D51681
-rw-r--r--include/dirent.h3
-rw-r--r--lib/libc/gen/readdir.c2
2 files changed, 4 insertions, 1 deletions
diff --git a/include/dirent.h b/include/dirent.h
index dff0e8675722..7fcdceb10b23 100644
--- a/include/dirent.h
+++ b/include/dirent.h
@@ -116,7 +116,8 @@ DIR *fdopendir(int);
struct dirent *
readdir(DIR *);
#if __POSIX_VISIBLE >= 199506 || __XSI_VISIBLE >= 500
-int readdir_r(DIR *, struct dirent *, struct dirent **);
+int readdir_r(DIR *, struct dirent *, struct dirent **)
+ __deprecated1("Does not take variable {NAME_MAX} into account");
#endif
void rewinddir(DIR *);
#if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE >= 700
diff --git a/lib/libc/gen/readdir.c b/lib/libc/gen/readdir.c
index b70102954df1..94d2b2e8d877 100644
--- a/lib/libc/gen/readdir.c
+++ b/lib/libc/gen/readdir.c
@@ -134,3 +134,5 @@ __readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result)
}
__strong_reference(__readdir_r, readdir_r);
+__warn_references(readdir_r,
+ "warning: this program uses readdir_r(), which is unsafe.");