Re: [RFC][PATCH] string.h: Add strncmp_prefix() helper macro

2018-12-19 Thread Steven Rostedt
[ Another email not as my daughter. ] On Wed, Dec 19, 2018 at 02:05:32PM -0800, Joe Perches wrote: > On Wed, 2018-12-19 at 16:32 -0500, Bryana Rostedt wrote: > > a quick grep in the kernel tree found several > > (thousands!) of cases that use this construct. A quick grep also > > revealed that

Re: [RFC][PATCH] string.h: Add strncmp_prefix() helper macro

2018-12-19 Thread Steven Rostedt
[ Sending now as myself and not my daughter :-p ] On Wed, Dec 19, 2018 at 01:54:57PM -0800, Joe Perches wrote: > On Wed, 2018-12-19 at 16:32 -0500, Bryana Rostedt wrote: > > > > +/* > > + * A common way to test a prefix of a string is to do: > > + * strncmp(str, prefix, sizeof(prefix) - 1) > >

Re: [RFC][PATCH] string.h: Add strncmp_prefix() helper macro

2018-12-19 Thread Steven Rostedt
Seems that I sent this as my daughter. I'm not home now but will resend again as myself when I am. -- Steve On December 19, 2018 4:54:57 PM EST, Joe Perches wrote: >On Wed, 2018-12-19 at 16:32 -0500, Bryana Rostedt wrote: >> A discussion came up in the trace triggers thread about converting a

Re: [RFC][PATCH] string.h: Add strncmp_prefix() helper macro

2018-12-19 Thread Joe Perches
On Wed, 2018-12-19 at 16:32 -0500, Bryana Rostedt wrote: > a quick grep in the kernel tree found several > (thousands!) of cases that use this construct. A quick grep also > revealed that there's probably several bugs in that use case. Some are > that people forgot the "- 1" (which I found) and

Re: [RFC][PATCH] string.h: Add strncmp_prefix() helper macro

2018-12-19 Thread Joe Perches
On Wed, 2018-12-19 at 16:32 -0500, Bryana Rostedt wrote: > 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: > > #define strncmp_const(str, const) \ >

[RFC][PATCH] string.h: Add strncmp_prefix() helper macro

2018-12-19 Thread Bryana Rostedt
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: #define strncmp_const(str, const) \ strncmp(str, const, sizeof(const) - 1) But then Joe Perches mentioned that if a