Skip to content

Commit 2d8ae9a

Browse files
andy-shevkees
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Kees Cook <[email protected]>
1 parent 10299c0 commit 2d8ae9a

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

include/linux/string.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -345,16 +345,6 @@ extern ssize_t memory_read_from_buffer(void *to, size_t count, loff_t *ppos,
345345

346346
int ptr_to_hashval(const void *ptr, unsigned long *hashval_out);
347347

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-
358348
size_t memweight(const void *ptr, size_t bytes);
359349

360350
/**
@@ -562,4 +552,14 @@ static __always_inline size_t str_has_prefix(const char *str, const char *prefix
562552
return strncmp(str, prefix, len) == 0 ? len : 0;
563553
}
564554

555+
/**
556+
* strstarts - does @str start with @prefix?
557+
* @str: string to examine
558+
* @prefix: prefix to look for.
559+
*/
560+
static inline bool strstarts(const char *str, const char *prefix)
561+
{
562+
return strncmp(str, prefix, strlen(prefix)) == 0;
563+
}
564+
565565
#endif /* _LINUX_STRING_H_ */

0 commit comments

Comments
 (0)