lkml.org 
[lkml]   [2019]   [Jan]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v12 01/16] tracing: Use str_has_prefix() in synth_event_create()
From
Date
On Tue, 2019-01-15 at 16:05 -0600, Tom Zanussi wrote:
> Since we now have a str_has_prefix() that returns the length, we can
> use that instead of explicitly calculating it.
[]
> diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
[]
> @@ -1200,8 +1200,7 @@ static int synth_event_create(int argc, const char **argv)
>
> /* This interface accepts group name prefix */
> if (strchr(name, '/')) {
> - len = sizeof(SYNTH_SYSTEM "/") - 1;
> - if (strncmp(name, SYNTH_SYSTEM "/", len))
> + if ((len = str_has_prefix(name, SYNTH_SYSTEM "/")) == 0)

Since this is a single test, and not multiple if/else if
blocks, I believe this would read better on two lines

len = str_has_prefix(name, SYNTH_SYSTEM "/");
if (len == 0)

> return -EINVAL;
> name += len;
> }


\
 
 \ /
  Last update: 2019-01-16 06:00    [W:0.125 / U:0.352 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site