[PATCH v5 7/7] string: Implement strstarts() with strprefix()

From: Alejandro Colomar

Date: Fri Nov 13 2026 - 09:55:20 EST


The compiler should be able to optimize out the unused pointer
arithmetic done at the end, so performance-wise this shouldn't change
anything.

This change de-duplicates the almost-identical implementations,
and better shows the relationship between the two functions.

Signed-off-by: Alejandro Colomar <alx@xxxxxxxxxx>
---
include/linux/string.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/string.h b/include/linux/string.h
index b1468d3913f6..015d2c7ee6c2 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -608,7 +608,7 @@ static inline const char *strprefix(const char *s, const char *prefix)
*/
static inline bool strstarts(const char *str, const char *prefix)
{
- return strncmp(str, prefix, strlen(prefix)) == 0;
+ return strprefix(str, prefix);
}

/**
--
2.55.0

Attachment: signature.asc
Description: PGP signature