[PATCH v3 5/5] string: Make strprefix() const-qualifier-generic

From: Alejandro Colomar

Date: Tue Nov 10 2026 - 10:44:39 EST


Suggested-by: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>
Signed-off-by: Alejandro Colomar <alx@xxxxxxxxxx>
---
include/linux/string.h | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/linux/string.h b/include/linux/string.h
index 9e59f9697c9e..55ca4cb5122c 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -590,7 +590,9 @@ void memcpy_and_pad(void *dest, size_t dest_len, const void *src, size_t count,
* * @s+strlen(@prefix) if @s starts with @prefix
* * NULL if @s does not start with @prefix
*/
-static inline char *strprefix(const char *s, const char *prefix)
+#define strprefix(s, pfx) const_cast(CQChar_of(s) *, strprefix(s, pfx))
+
+static inline char *(strprefix)(const char *s, const char *prefix)
{
size_t len = strlen(prefix);
return strncmp(s, prefix, len) == 0 ? (char *) s + len : NULL;
--
2.55.0

Attachment: signature.asc
Description: PGP signature