From c1402fc74466c41f0c8663ceee1b96d7c2ccce84 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 21 Aug 2014 21:28:40 -0400 Subject: util: change return value of startswith() to non-const This way we can use it on non-const strings, and don't end up with a const'ified result. This is similar to libc's strstr() which also takes a const string but returns a non-const one. Signed-off-by: Anthony G. Basile --- src/shared/util.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/shared/util.h b/src/shared/util.h index dd1c515f90..d5c6705497 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -117,9 +117,13 @@ static inline bool isempty(const char *p) { return !p || !p[0]; } -static inline const char *startswith(const char *s, const char *prefix) { - if (strncmp(s, prefix, strlen(prefix)) == 0) - return s + strlen(prefix); +static inline 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 NULL; } -- cgit v1.2.3-54-g00ecf