From 44279ddda3a2ef27b47a38e18207d11b92cf5a18 Mon Sep 17 00:00:00 2001 From: Yaroslav Chvanov Date: Sun, 19 Mar 2023 02:02:09 +0300 Subject: [PATCH] shared-macro: make startswith() return a const char* The supplied arguments are const, and as such the return type which is derived from the arguments must also be const. --- src/shared-macro.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/shared-macro.h b/src/shared-macro.h index 9f9dba28..4ef015f8 100644 --- a/src/shared-macro.h +++ b/src/shared-macro.h @@ -235,13 +235,13 @@ static inline bool streq_ptr(const char *a, const char *b) * This returns a pointer to the first character in @s that follows @prefix. If * @s does not start with @prefix, NULL is returned. */ -static inline char *startswith(const char *s, const char *prefix) +static inline const char *startswith(const char *s, const char *prefix) { size_t l; l = strlen(prefix); if (strncmp(s, prefix, l) == 0) - return (char*) s + l; + return s + l; return NULL; }