Re: [PATCH v3] string.h: Add str_has_prefix() helper

2018-12-22 Thread Namhyung Kim
On Sat, Dec 22, 2018 at 07:22:07AM -0500, Steven Rostedt wrote: > On Sat, 22 Dec 2018 18:28:18 +0900 > Namhyung Kim wrote: > > > > > > > for (i = 0; i < hist_data->attrs->n_actions; i++) { > > > str = hist_data->attrs->action_str[i]; > > > > > > - if (str_has_prefix(str,

Re: [PATCH v3] string.h: Add str_has_prefix() helper

2018-12-22 Thread Ingo Molnar
* Steven Rostedt wrote: > On Fri, 21 Dec 2018 16:32:58 -0800 > Linus Torvalds wrote: > > > On Fri, Dec 21, 2018, 16:06 Steven Rostedt > > > > On Fri, 21 Dec 2018 18:13:16 > > > > > > And I'll make a separate patch that adds: > > > > > > static __always_inline bool > > >

Re: [PATCH v3] string.h: Add str_has_prefix() helper

2018-12-22 Thread Namhyung Kim
Hi Steve, On Fri, Dec 21, 2018 at 06:38:17PM -0500, Steven Rostedt wrote: > On Fri, 21 Dec 2018 18:25:07 -0500 > Steven Rostedt wrote: > > > On Fri, 21 Dec 2018 15:19:33 -0800 > > Joe Perches wrote: > > > > > I believe this should be bool. > > > > > > I don't find a use for non-zero assigned

Re: [PATCH v3] string.h: Add str_has_prefix() helper

2018-12-22 Thread Steven Rostedt
On Sat, 22 Dec 2018 11:58:45 +0100 Ingo Molnar wrote: > * Steven Rostedt wrote: > > > On Fri, 21 Dec 2018 16:32:58 -0800 > > Linus Torvalds wrote: > > > > > On Fri, Dec 21, 2018, 16:06 Steven Rostedt > > > > > > On Fri, 21 Dec 2018 18:13:16 > > > > > > > > And I'll make a separate

Re: [PATCH v3] string.h: Add str_has_prefix() helper

2018-12-22 Thread Steven Rostedt
On Sat, 22 Dec 2018 18:28:18 +0900 Namhyung Kim wrote: > > > > for (i = 0; i < hist_data->attrs->n_actions; i++) { > > str = hist_data->attrs->action_str[i]; > > > > - if (str_has_prefix(str, "onmatch(")) { > > - char *action_str = str +

Re: [PATCH v3] string.h: Add str_has_prefix() helper

2018-12-21 Thread Steven Rostedt
On Fri, 21 Dec 2018 16:32:58 -0800 Linus Torvalds wrote: > On Fri, Dec 21, 2018, 16:06 Steven Rostedt > > On Fri, 21 Dec 2018 18:13:16 > > > > 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

Re: [PATCH v3] string.h: Add str_has_prefix() helper

2018-12-21 Thread Joe Perches
On Fri, 2018-12-21 at 19:06 -0500, Steven Rostedt wrote: > On Fri, 21 Dec 2018 18:13:16 -0500 > Steven Rostedt 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

Re: [PATCH v3] string.h: Add str_has_prefix() helper

2018-12-21 Thread Steven Rostedt
On Fri, 21 Dec 2018 18:13:16 -0500 Steven Rostedt 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,

Re: [PATCH v3] string.h: Add str_has_prefix() helper

2018-12-21 Thread Steven Rostedt
On Fri, 21 Dec 2018 15:44:41 -0800 Joe Perches wrote: > On Fri, 2018-12-21 at 18:25 -0500, Steven Rostedt wrote: > > On Fri, 21 Dec 2018 15:19:33 -0800 > > Joe Perches wrote: > > > > > I believe this should be bool. > > > > > > I don't find a use for non-zero assigned len value in the

Re: [PATCH v3] string.h: Add str_has_prefix() helper

2018-12-21 Thread Joe Perches
On Fri, 2018-12-21 at 18:25 -0500, Steven Rostedt wrote: > On Fri, 21 Dec 2018 15:19:33 -0800 > Joe Perches wrote: > > > I believe this should be bool. > > > > I don't find a use for non-zero assigned len value in the kernel > > for strncmp and I believe the function should simply be: > > > >

Re: [PATCH v3] string.h: Add str_has_prefix() helper

2018-12-21 Thread Steven Rostedt
On Fri, 21 Dec 2018 18:25:07 -0500 Steven Rostedt wrote: > On Fri, 21 Dec 2018 15:19:33 -0800 > Joe Perches wrote: > > > I believe this should be bool. > > > > I don't find a use for non-zero assigned len value in the kernel > > for strncmp and I believe the function should simply be: > > >

Re: [PATCH v3] string.h: Add str_has_prefix() helper

2018-12-21 Thread Steven Rostedt
On Fri, 21 Dec 2018 15:19:33 -0800 Joe Perches wrote: > I believe this should be bool. > > I don't find a use for non-zero assigned len value in the kernel > for strncmp and I believe the function should simply be: > > static inline bool str_has_prefix(const char *str, const char prefix[]) > {

Re: [PATCH v3] string.h: Add str_has_prefix() helper

2018-12-21 Thread Joe Perches
On Fri, 2018-12-21 at 18:13 -0500, Steven Rostedt wrote: > From: "Steven Rostedt (VMware)" > > A discussion came up in the trace triggers thread about converting a > bunch of: > > strncmp(str, "const", sizeof("const") - 1) > > use cases into a helper macro. It started with: > >