summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBartosz Golaszewski <bartosz.golaszewski@linaro.org>2025-11-18 11:04:04 +0100
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>2025-11-25 11:22:08 +0100
commit194832dcb13b0d02fce0df887235b7e6d1ef0121 (patch)
tree738989acc6b9107e7686e6047fcb3eb34dea1fbf
parent72eb5b1f5d7c0ab76e4db1b2d4eb8a880dbdbfad (diff)
string: use __attribute__((nonnull())) in strends()
The arguments of strends() must not be NULL so annotate the function with the nonnull attribute. Suggested-by: Kees Cook <kees@kernel.org> Link: https://lore.kernel.org/r/20251118-strends-follow-up-v1-2-d3f8ef750f59@linaro.org Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
-rw-r--r--include/linux/string.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/include/linux/string.h b/include/linux/string.h
index 69e9256592f8..0266dbdaa4cd 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -570,7 +570,8 @@ static inline bool strstarts(const char *str, const char *prefix)
* Returns:
* True if @str ends with @suffix. False in all other cases.
*/
-static inline bool strends(const char *str, const char *suffix)
+static inline bool __attribute__((nonnull(1, 2)))
+strends(const char *str, const char *suffix)
{
unsigned int str_len = strlen(str), suffix_len = strlen(suffix);