nuttx/libs/libc/dirent
yushuailong 7e67d2d906 libs/libc/dirent: preserve errno on readdir() end-of-directory
readdir() returned NULL at end-of-directory without ensuring errno was
clean.  POSIX requires errno to be unchanged at EOF, but the underlying
read() path may leave a stale errno value.  Callers that follow the
POSIX idiom (set errno to 0 before the call, test it after a NULL
return), such as readdir_r() and scandir(), then misread this as a
readdir() failure.

Save errno on entry and restore it on the end-of-directory return so
that EOF no longer reports a spurious error, while genuine errors
(read() returning a negative value) still propagate.

Signed-off-by: yushuailong <yyyusl@qq.com>
2026-06-02 23:34:25 +08:00
..
CMakeLists.txt
lib_alphasort.c
lib_closedir.c
lib_dirfd.c
lib_fdopendir.c
lib_ftw.c
lib_nftw.c
lib_opendir.c
lib_readdir.c libs/libc/dirent: preserve errno on readdir() end-of-directory 2026-06-02 23:34:25 +08:00
lib_readdirr.c
lib_rewinddir.c
lib_scandir.c
lib_seekdir.c
lib_telldir.c
lib_versionsort.c
Make.defs