diff options
author | Yisheng Xie <xieyisheng1@huawei.com> | 2018-05-17 10:36:03 +0200 |
---|---|---|
committer | Steven Rostedt (VMware) <rostedt@goodmis.org> | 2018-06-05 22:19:39 +0200 |
commit | 591a033dc17ff6f684b6b6d1d7426e22d178194f (patch) | |
tree | b750268257835c9736e46837e6fb526c378a6cb7 /kernel/trace/trace.c | |
parent | branch-check: fix long->int truncation when profiling branches (diff) | |
download | linux-591a033dc17ff6f684b6b6d1d7426e22d178194f.tar.xz linux-591a033dc17ff6f684b6b6d1d7426e22d178194f.zip |
tracing: Use match_string() instead of open coding it in trace_set_options()
match_string() returns the index of an array for a matching string,
which can be used to simplify the code.
Link: http://lkml.kernel.org/r/1526546163-4609-1-git-send-email-xieyisheng1@huawei.com
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace/trace.c')
-rw-r--r-- | kernel/trace/trace.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index e69820f77b33..108ce3e1dc13 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -4395,8 +4395,7 @@ static int trace_set_options(struct trace_array *tr, char *option) { char *cmp; int neg = 0; - int ret = -ENODEV; - int i; + int ret; size_t orig_len = strlen(option); cmp = strstrip(option); @@ -4408,16 +4407,12 @@ static int trace_set_options(struct trace_array *tr, char *option) mutex_lock(&trace_types_lock); - for (i = 0; trace_options[i]; i++) { - if (strcmp(cmp, trace_options[i]) == 0) { - ret = set_tracer_flag(tr, 1 << i, !neg); - break; - } - } - + ret = match_string(trace_options, -1, cmp); /* If no option could be set, test the specific tracer options */ - if (!trace_options[i]) + if (ret < 0) ret = set_tracer_option(tr, cmp, neg); + else + ret = set_tracer_flag(tr, 1 << ret, !neg); mutex_unlock(&trace_types_lock); |