diff --git a/libc/include/dirent.h b/libc/include/dirent.h index 2328b1a8a..2751b9e76 100644 --- a/libc/include/dirent.h +++ b/libc/include/dirent.h @@ -95,7 +95,7 @@ typedef struct DIR DIR; * * Returns null and sets `errno` on failure. */ -DIR* opendir(const char* __path); +DIR* _Nullable opendir(const char* _Nonnull __path); /** * [fopendir(3)](http://man7.org/linux/man-pages/man3/opendir.3.html) @@ -103,7 +103,7 @@ DIR* opendir(const char* __path); * * Returns null and sets `errno` on failure. */ -DIR* fdopendir(int __dir_fd); +DIR* _Nullable fdopendir(int __dir_fd); /** * [readdir(3)](http://man7.org/linux/man-pages/man3/readdir.3.html) @@ -113,7 +113,7 @@ DIR* fdopendir(int __dir_fd); * or returns null and leaves `errno` unchanged at the end of the directory, * or returns null and sets `errno` on failure. */ -struct dirent* readdir(DIR* __dir); +struct dirent* _Nullable readdir(DIR* _Nonnull __dir); /** * [readdir64(3)](http://man7.org/linux/man-pages/man3/readdir.3.html) @@ -123,10 +123,10 @@ struct dirent* readdir(DIR* __dir); * or returns null and leaves `errno` unchanged at the end of the directory, * or returns null and sets `errno` on failure. */ -struct dirent64* readdir64(DIR* __dir) __INTRODUCED_IN(21); +struct dirent64* _Nullable readdir64(DIR* _Nonnull __dir) __INTRODUCED_IN(21); -int readdir_r(DIR* __dir, struct dirent* __entry, struct dirent** __buffer) __attribute__((__deprecated__("readdir_r is deprecated; use readdir instead"))); -int readdir64_r(DIR* __dir, struct dirent64* __entry, struct dirent64** __buffer) __INTRODUCED_IN(21) __attribute__((__deprecated__("readdir64_r is deprecated; use readdir64 instead"))); +int readdir_r(DIR* _Nonnull __dir, struct dirent* _Nonnull __entry, struct dirent* _Nullable * _Nonnull __buffer) __attribute__((__deprecated__("readdir_r is deprecated; use readdir instead"))); +int readdir64_r(DIR* _Nonnull __dir, struct dirent64* _Nonnull __entry, struct dirent64* _Nullable * _Nonnull __buffer) __INTRODUCED_IN(21) __attribute__((__deprecated__("readdir64_r is deprecated; use readdir64 instead"))); /** * [closedir(3)](http://man7.org/linux/man-pages/man3/closedir.3.html) @@ -134,13 +134,13 @@ int readdir64_r(DIR* __dir, struct dirent64* __entry, struct dirent64** __buffer * * Returns 0 on success and returns -1 and sets `errno` on failure. */ -int closedir(DIR* __dir); +int closedir(DIR* _Nonnull __dir); /** * [rewinddir(3)](http://man7.org/linux/man-pages/man3/rewinddir.3.html) * rewinds a directory stream to the first entry. */ -void rewinddir(DIR* __dir); +void rewinddir(DIR* _Nonnull __dir); /** * [seekdir(3)](http://man7.org/linux/man-pages/man3/seekdir.3.html) @@ -149,7 +149,7 @@ void rewinddir(DIR* __dir); * * Available since API level 23. */ -void seekdir(DIR* __dir, long __location) __INTRODUCED_IN(23); +void seekdir(DIR* _Nonnull __dir, long __location) __INTRODUCED_IN(23); /** * [telldir(3)](http://man7.org/linux/man-pages/man3/telldir.3.html) @@ -160,7 +160,7 @@ void seekdir(DIR* __dir, long __location) __INTRODUCED_IN(23); * * Available since API level 23. */ -long telldir(DIR* __dir) __INTRODUCED_IN(23); +long telldir(DIR* _Nonnull __dir) __INTRODUCED_IN(23); /** * [dirfd(3)](http://man7.org/linux/man-pages/man3/dirfd.3.html) @@ -168,13 +168,13 @@ long telldir(DIR* __dir) __INTRODUCED_IN(23); * * Returns a file descriptor on success and returns -1 and sets `errno` on failure. */ -int dirfd(DIR* __dir); +int dirfd(DIR* _Nonnull __dir); /** * [alphasort](http://man7.org/linux/man-pages/man3/alphasort.3.html) is a * comparator for use with scandir() that uses strcoll(). */ -int alphasort(const struct dirent** __lhs, const struct dirent** __rhs); +int alphasort(const struct dirent* _Nonnull * _Nonnull __lhs, const struct dirent* _Nonnull * _Nonnull __rhs); /** * [alphasort64](http://man7.org/linux/man-pages/man3/alphasort.3.html) is a @@ -182,31 +182,33 @@ int alphasort(const struct dirent** __lhs, const struct dirent** __rhs); * * Available since API level 21. */ -int alphasort64(const struct dirent64** __lhs, const struct dirent64** __rhs) __INTRODUCED_IN(21); +int alphasort64(const struct dirent64* _Nonnull * _Nonnull __lhs, const struct dirent64* _Nonnull * _Nonnull __rhs) __INTRODUCED_IN(21); /** * [scandir(3)](http://man7.org/linux/man-pages/man3/scandir.3.html) * scans all the directory `__path`, filtering entries with `__filter` and * sorting them with qsort() using the given `__comparator`, and storing them * into `__name_list`. Passing NULL as the filter accepts all entries. + * Passing NULL as the comparator skips sorting. * * Returns the number of entries returned in the list on success, * and returns -1 and sets `errno` on failure. */ -int scandir(const char* __path, struct dirent*** __name_list, int (*__filter)(const struct dirent*), int (*__comparator)(const struct dirent**, const struct dirent**)); +int scandir(const char* _Nonnull __path, struct dirent* _Nonnull * _Nonnull * _Nonnull __name_list, int (* _Nullable __filter)(const struct dirent* _Nonnull), int (* _Nullable __comparator)(const struct dirent* _Nonnull * _Nonnull, const struct dirent* _Nonnull * _Nonnull)); /** * [scandir64(3)](http://man7.org/linux/man-pages/man3/scandir.3.html) * scans all the directory `__path`, filtering entries with `__filter` and * sorting them with qsort() using the given `__comparator`, and storing them * into `__name_list`. Passing NULL as the filter accepts all entries. + * Passing NULL as the comparator skips sorting. * * Returns the number of entries returned in the list on success, * and returns -1 and sets `errno` on failure. * * Available since API level 21. */ -int scandir64(const char* __path, struct dirent64*** __name_list, int (*__filter)(const struct dirent64*), int (*__comparator)(const struct dirent64**, const struct dirent64**)) __INTRODUCED_IN(21); +int scandir64(const char* _Nonnull __path, struct dirent64* _Nonnull * _Nonnull * _Nonnull __name_list, int (* _Nullable __filter)(const struct dirent64* _Nonnull), int (* _Nullable __comparator)(const struct dirent64* _Nonnull * _Nonnull, const struct dirent64* _Nonnull * _Nonnull)) __INTRODUCED_IN(21); #if defined(__USE_GNU) @@ -216,13 +218,14 @@ int scandir64(const char* __path, struct dirent64*** __name_list, int (*__filter * filtering entries with `__filter` and sorting them with qsort() using the * given `__comparator`, and storing them into `__name_list`. Passing NULL as * the filter accepts all entries. + * Passing NULL as the comparator skips sorting. * * Returns the number of entries returned in the list on success, * and returns -1 and sets `errno` on failure. * * Available since API level 24. */ -int scandirat64(int __dir_fd, const char* __path, struct dirent64*** __name_list, int (*__filter)(const struct dirent64*), int (*__comparator)(const struct dirent64**, const struct dirent64**)) __INTRODUCED_IN(24); +int scandirat64(int __dir_fd, const char* _Nonnull __path, struct dirent64* _Nonnull * _Nonnull * _Nonnull __name_list, int (* _Nullable __filter)(const struct dirent64* _Nonnull), int (* _Nullable __comparator)(const struct dirent64* _Nonnull * _Nonnull, const struct dirent64* _Nonnull * _Nonnull)) __INTRODUCED_IN(24); /** * [scandirat(3)](http://man7.org/linux/man-pages/man3/scandirat.3.html) @@ -230,13 +233,14 @@ int scandirat64(int __dir_fd, const char* __path, struct dirent64*** __name_list * filtering entries with `__filter` and sorting them with qsort() using the * given `__comparator`, and storing them into `__name_list`. Passing NULL as * the filter accepts all entries. + * Passing NULL as the comparator skips sorting. * * Returns the number of entries returned in the list on success, * and returns -1 and sets `errno` on failure. * * Available since API level 24. */ -int scandirat(int __dir_fd, const char* __path, struct dirent*** __name_list, int (*__filter)(const struct dirent*), int (*__comparator)(const struct dirent**, const struct dirent**)) __INTRODUCED_IN(24); +int scandirat(int __dir_fd, const char* _Nonnull __path, struct dirent* _Nonnull * _Nonnull * _Nonnull __name_list, int (* _Nullable __filter)(const struct dirent* _Nonnull), int (* _Nullable __comparator)(const struct dirent* _Nonnull * _Nonnull, const struct dirent* _Nonnull * _Nonnull)) __INTRODUCED_IN(24); #endif