Messages in this thread | | | Date | Fri, 21 Dec 2018 19:06:29 -0500 | From | Steven Rostedt <> | Subject | Re: [PATCH v3] string.h: Add str_has_prefix() helper |
| |
On Fri, 21 Dec 2018 18:13:16 -0500 Steven Rostedt <rostedt@goodmis.org> wrote:
> +static __always_inline int str_has_prefix(const char *str, const char *prefix)
I'm thinking it is cleaner to have two helper functions and have them both return bool.
static __always_inline bool str_has_prefix(const char *str, const char *prefix) { return !strncmp(str, prefix, strlen(prefix)); }
( I still like to keep the __always_inline, it doesn't hurt )
And I'll make a separate patch that adds:
static __always_inline bool str_has_prefix_len(const char *str, const char *prefix, unsigned int *len) { *len = strlen(prefix); return !strncmp(str, prefix, *len) ? *len : 0; }
Everyone OK with that?
-- Steve
| |