Skip to content

Commit

Permalink
tracing: Use match_string() instead of open coding it in trace_set_op…
Browse files Browse the repository at this point in the history
…tions()

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/[email protected]

Reviewed-by: Andy Shevchenko <[email protected]>
Signed-off-by: Yisheng Xie <[email protected]>
Signed-off-by: Steven Rostedt (VMware) <[email protected]>
  • Loading branch information
Yisheng Xie authored and rostedt committed Jun 5, 2018
1 parent 2026d35 commit 591a033
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions kernel/trace/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);

Expand Down

0 comments on commit 591a033

Please sign in to comment.