Skip to content

Commit 194832d

Browse files
author
Bartosz Golaszewski
committed
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>
1 parent 72eb5b1 commit 194832d

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

include/linux/string.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,8 @@ static inline bool strstarts(const char *str, const char *prefix)
570570
* Returns:
571571
* True if @str ends with @suffix. False in all other cases.
572572
*/
573-
static inline bool strends(const char *str, const char *suffix)
573+
static inline bool __attribute__((nonnull(1, 2)))
574+
strends(const char *str, const char *suffix)
574575
{
575576
unsigned int str_len = strlen(str), suffix_len = strlen(suffix);
576577

0 commit comments

Comments
 (0)