From d4c54b44488c3e3f8eb35635645aecdfdb8b5636 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Fri, 31 May 2024 17:33:33 +0000 Subject: [PATCH] Warn about unused results with bsearch(). This function has no side-effects, and the return value is the whole point. Change-Id: Ibb9143c6a3c4089bfd6402c1c580ef76ce0f5d27 --- libc/include/stdlib.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libc/include/stdlib.h b/libc/include/stdlib.h index 506ab43ba..d0efc4c3a 100644 --- a/libc/include/stdlib.h +++ b/libc/include/stdlib.h @@ -105,7 +105,14 @@ __wur char* _Nullable realpath(const char* _Nonnull __path, char* _Nullable __re */ int system(const char* _Nonnull __command); -void* _Nullable bsearch(const void* _Nonnull __key, const void* _Nullable __base, size_t __nmemb, size_t __size, int (* _Nonnull __comparator)(const void* _Nonnull __lhs, const void* _Nonnull __rhs)); +/** + * [bsearch(3)](http://man7.org/linux/man-pages/man3/bsearch.3.html) searches + * a sorted array. + * + * Returns a pointer to a matching item on success, + * or NULL if no matching item is found. + */ +__wur void* _Nullable bsearch(const void* _Nonnull __key, const void* _Nullable __base, size_t __nmemb, size_t __size, int (* _Nonnull __comparator)(const void* _Nonnull __lhs, const void* _Nonnull __rhs)); void qsort(void* _Nullable __base, size_t __nmemb, size_t __size, int (* _Nonnull __comparator)(const void* _Nullable __lhs, const void* _Nullable __rhs));