Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

string: Group str_has_prefix() and strstarts()

The two str_has_prefix() and strstarts() are about the same
with a slight difference on what they return. Group them in
the header.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20250711085514.1294428-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Kees Cook <kees@kernel.org>

authored by

Andy Shevchenko and committed by
Kees Cook
2d8ae9a4 10299c07

+10 -10
+10 -10
include/linux/string.h
··· 345 345 346 346 int ptr_to_hashval(const void *ptr, unsigned long *hashval_out); 347 347 348 - /** 349 - * strstarts - does @str start with @prefix? 350 - * @str: string to examine 351 - * @prefix: prefix to look for. 352 - */ 353 - static inline bool strstarts(const char *str, const char *prefix) 354 - { 355 - return strncmp(str, prefix, strlen(prefix)) == 0; 356 - } 357 - 358 348 size_t memweight(const void *ptr, size_t bytes); 359 349 360 350 /** ··· 550 560 { 551 561 size_t len = strlen(prefix); 552 562 return strncmp(str, prefix, len) == 0 ? len : 0; 563 + } 564 + 565 + /** 566 + * strstarts - does @str start with @prefix? 567 + * @str: string to examine 568 + * @prefix: prefix to look for. 569 + */ 570 + static inline bool strstarts(const char *str, const char *prefix) 571 + { 572 + return strncmp(str, prefix, strlen(prefix)) == 0; 553 573 } 554 574 555 575 #endif /* _LINUX_STRING_H_ */