Skip to content

Commit f75340d

Browse files
committed
tracing: Remove unnecessary "goto out" that simply returns ret is trigger code
There's several functions that have "goto out;" where the label out is just: out: return ret; Simplify the code by just doing the return in the location and removing all the out labels and jumps. Cc: Masami Hiramatsu <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Mathieu Desnoyers <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Tom Zanussi <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent c5dd28e commit f75340d

File tree

1 file changed

+17
-27
lines changed

1 file changed

+17
-27
lines changed

kernel/trace/trace_events_trigger.c

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -552,16 +552,14 @@ static int register_trigger(char *glob,
552552
lockdep_assert_held(&event_mutex);
553553

554554
list_for_each_entry(test, &file->triggers, list) {
555-
if (test->cmd_ops->trigger_type == data->cmd_ops->trigger_type) {
556-
ret = -EEXIST;
557-
goto out;
558-
}
555+
if (test->cmd_ops->trigger_type == data->cmd_ops->trigger_type)
556+
return -EEXIST;
559557
}
560558

561559
if (data->ops->init) {
562560
ret = data->ops->init(data);
563561
if (ret < 0)
564-
goto out;
562+
return ret;
565563
}
566564

567565
list_add_rcu(&data->list, &file->triggers);
@@ -572,7 +570,6 @@ static int register_trigger(char *glob,
572570
list_del_rcu(&data->list);
573571
update_cond_flag(file);
574572
}
575-
out:
576573
return ret;
577574
}
578575

@@ -770,7 +767,7 @@ int event_trigger_separate_filter(char *param_and_filter, char **param,
770767
if (!param_and_filter) {
771768
if (param_required)
772769
ret = -EINVAL;
773-
goto out;
770+
return ret;
774771
}
775772

776773
/*
@@ -781,7 +778,7 @@ int event_trigger_separate_filter(char *param_and_filter, char **param,
781778
*/
782779
if (!param_required && param_and_filter && !isdigit(param_and_filter[0])) {
783780
*filter = param_and_filter;
784-
goto out;
781+
return ret;
785782
}
786783

787784
/*
@@ -799,7 +796,6 @@ int event_trigger_separate_filter(char *param_and_filter, char **param,
799796
if (!**filter)
800797
*filter = NULL;
801798
}
802-
out:
803799
return ret;
804800
}
805801

@@ -991,13 +987,12 @@ event_trigger_parse(struct event_command *cmd_ops,
991987
ret = -ENOMEM;
992988
trigger_data = trigger_data_alloc(cmd_ops, cmd, param, file);
993989
if (!trigger_data)
994-
goto out;
990+
return ret;
995991

996992
if (remove) {
997993
event_trigger_unregister(cmd_ops, file, glob+1, trigger_data);
998994
trigger_data_free(trigger_data);
999-
ret = 0;
1000-
goto out;
995+
return 0;
1001996
}
1002997

1003998
ret = event_trigger_parse_num(param, trigger_data);
@@ -1017,13 +1012,12 @@ event_trigger_parse(struct event_command *cmd_ops,
10171012

10181013
/* Down the counter of trigger_data or free it if not used anymore */
10191014
event_trigger_free(trigger_data);
1020-
out:
10211015
return ret;
10221016

10231017
out_free:
10241018
event_trigger_reset_filter(cmd_ops, trigger_data);
10251019
trigger_data_free(trigger_data);
1026-
goto out;
1020+
return ret;
10271021
}
10281022

10291023
/**
@@ -1057,10 +1051,10 @@ int set_trigger_filter(char *filter_str,
10571051
s = strsep(&filter_str, " \t");
10581052

10591053
if (!strlen(s) || strcmp(s, "if") != 0)
1060-
goto out;
1054+
return ret;
10611055

10621056
if (!filter_str)
1063-
goto out;
1057+
return ret;
10641058

10651059
/* The filter is for the 'trigger' event, not the triggered event */
10661060
ret = create_event_filter(file->tr, file->event_call,
@@ -1104,7 +1098,6 @@ int set_trigger_filter(char *filter_str,
11041098
ret = -ENOMEM;
11051099
}
11061100
}
1107-
out:
11081101
return ret;
11091102
}
11101103

@@ -1772,7 +1765,7 @@ int event_enable_trigger_parse(struct event_command *cmd_ops,
17721765
ret = -EINVAL;
17731766
event_enable_file = find_event_file(tr, system, event);
17741767
if (!event_enable_file)
1775-
goto out;
1768+
return ret;
17761769

17771770
#ifdef CONFIG_HIST_TRIGGERS
17781771
hist = ((strcmp(cmd, ENABLE_HIST_STR) == 0) ||
@@ -1787,7 +1780,7 @@ int event_enable_trigger_parse(struct event_command *cmd_ops,
17871780

17881781
enable_data = kzalloc(sizeof(*enable_data), GFP_KERNEL);
17891782
if (!enable_data)
1790-
goto out;
1783+
return ret;
17911784

17921785
enable_data->hist = hist;
17931786
enable_data->enable = enable;
@@ -1796,15 +1789,15 @@ int event_enable_trigger_parse(struct event_command *cmd_ops,
17961789
trigger_data = trigger_data_alloc(cmd_ops, cmd, param, enable_data);
17971790
if (!trigger_data) {
17981791
kfree(enable_data);
1799-
goto out;
1792+
return ret;
18001793
}
18011794

18021795
if (remove) {
18031796
event_trigger_unregister(cmd_ops, file, glob+1, trigger_data);
18041797
kfree(trigger_data);
18051798
kfree(enable_data);
18061799
ret = 0;
1807-
goto out;
1800+
return ret;
18081801
}
18091802

18101803
/* Up the trigger_data count to make sure nothing frees it on failure */
@@ -1834,7 +1827,6 @@ int event_enable_trigger_parse(struct event_command *cmd_ops,
18341827
goto out_disable;
18351828

18361829
event_trigger_free(trigger_data);
1837-
out:
18381830
return ret;
18391831
out_disable:
18401832
trace_event_enable_disable(event_enable_file, 0, 1);
@@ -1845,7 +1837,7 @@ int event_enable_trigger_parse(struct event_command *cmd_ops,
18451837
event_trigger_free(trigger_data);
18461838
kfree(enable_data);
18471839

1848-
goto out;
1840+
return ret;
18491841
}
18501842

18511843
int event_enable_register_trigger(char *glob,
@@ -1865,15 +1857,14 @@ int event_enable_register_trigger(char *glob,
18651857
(test->cmd_ops->trigger_type ==
18661858
data->cmd_ops->trigger_type) &&
18671859
(test_enable_data->file == enable_data->file)) {
1868-
ret = -EEXIST;
1869-
goto out;
1860+
return -EEXIST;
18701861
}
18711862
}
18721863

18731864
if (data->ops->init) {
18741865
ret = data->ops->init(data);
18751866
if (ret < 0)
1876-
goto out;
1867+
return ret;
18771868
}
18781869

18791870
list_add_rcu(&data->list, &file->triggers);
@@ -1884,7 +1875,6 @@ int event_enable_register_trigger(char *glob,
18841875
list_del_rcu(&data->list);
18851876
update_cond_flag(file);
18861877
}
1887-
out:
18881878
return ret;
18891879
}
18901880

0 commit comments

Comments
 (0)