Skip to content

Commit c89504a

Browse files
committed
tracing: Remove unneeded goto out logic
Several places in the trace.c file there's a goto out where the out is simply a return. There's no reason to jump to the out label if it's not doing any more logic but simply returning from the function. Replace the goto outs with a return and remove the out labels. Cc: Masami Hiramatsu <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Mathieu Desnoyers <[email protected]> Cc: Andrew Morton <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent 623526b commit c89504a

File tree

1 file changed

+15
-23
lines changed

1 file changed

+15
-23
lines changed

kernel/trace/trace.c

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1841,7 +1841,7 @@ int trace_get_user(struct trace_parser *parser, const char __user *ubuf,
18411841

18421842
ret = get_user(ch, ubuf++);
18431843
if (ret)
1844-
goto out;
1844+
return ret;
18451845

18461846
read++;
18471847
cnt--;
@@ -1855,7 +1855,7 @@ int trace_get_user(struct trace_parser *parser, const char __user *ubuf,
18551855
while (cnt && isspace(ch)) {
18561856
ret = get_user(ch, ubuf++);
18571857
if (ret)
1858-
goto out;
1858+
return ret;
18591859
read++;
18601860
cnt--;
18611861
}
@@ -1865,22 +1865,20 @@ int trace_get_user(struct trace_parser *parser, const char __user *ubuf,
18651865
/* only spaces were written */
18661866
if (isspace(ch) || !ch) {
18671867
*ppos += read;
1868-
ret = read;
1869-
goto out;
1868+
return read;
18701869
}
18711870
}
18721871

18731872
/* read the non-space input */
18741873
while (cnt && !isspace(ch) && ch) {
18751874
if (parser->idx < parser->size - 1)
18761875
parser->buffer[parser->idx++] = ch;
1877-
else {
1878-
ret = -EINVAL;
1879-
goto out;
1880-
}
1876+
else
1877+
return -EINVAL;
1878+
18811879
ret = get_user(ch, ubuf++);
18821880
if (ret)
1883-
goto out;
1881+
return ret;
18841882
read++;
18851883
cnt--;
18861884
}
@@ -1895,15 +1893,11 @@ int trace_get_user(struct trace_parser *parser, const char __user *ubuf,
18951893
/* Make sure the parsed string always terminates with '\0'. */
18961894
parser->buffer[parser->idx] = 0;
18971895
} else {
1898-
ret = -EINVAL;
1899-
goto out;
1896+
return -EINVAL;
19001897
}
19011898

19021899
*ppos += read;
1903-
ret = read;
1904-
1905-
out:
1906-
return ret;
1900+
return read;
19071901
}
19081902

19091903
/* TODO add a seq_buf_to_buffer() */
@@ -2405,10 +2399,10 @@ int __init register_tracer(struct tracer *type)
24052399
mutex_unlock(&trace_types_lock);
24062400

24072401
if (ret || !default_bootup_tracer)
2408-
goto out_unlock;
2402+
return ret;
24092403

24102404
if (strncmp(default_bootup_tracer, type->name, MAX_TRACER_SIZE))
2411-
goto out_unlock;
2405+
return 0;
24122406

24132407
printk(KERN_INFO "Starting tracer '%s'\n", type->name);
24142408
/* Do we want this tracer to start on bootup? */
@@ -2420,8 +2414,7 @@ int __init register_tracer(struct tracer *type)
24202414
/* disable other selftests, since this will break it. */
24212415
disable_tracing_selftest("running a tracer");
24222416

2423-
out_unlock:
2424-
return ret;
2417+
return 0;
24252418
}
24262419

24272420
static void tracing_reset_cpu(struct array_buffer *buf, int cpu)
@@ -8963,12 +8956,12 @@ ftrace_trace_snapshot_callback(struct trace_array *tr, struct ftrace_hash *hash,
89638956
out_reg:
89648957
ret = tracing_arm_snapshot(tr);
89658958
if (ret < 0)
8966-
goto out;
8959+
return ret;
89678960

89688961
ret = register_ftrace_function_probe(glob, tr, ops, count);
89698962
if (ret < 0)
89708963
tracing_disarm_snapshot(tr);
8971-
out:
8964+
89728965
return ret < 0 ? ret : 0;
89738966
}
89748967

@@ -11070,7 +11063,7 @@ __init static int tracer_alloc_buffers(void)
1107011063
BUILD_BUG_ON(TRACE_ITER_LAST_BIT > TRACE_FLAGS_MAX_SIZE);
1107111064

1107211065
if (!alloc_cpumask_var(&tracing_buffer_mask, GFP_KERNEL))
11073-
goto out;
11066+
return -ENOMEM;
1107411067

1107511068
if (!alloc_cpumask_var(&global_trace.tracing_cpumask, GFP_KERNEL))
1107611069
goto out_free_buffer_mask;
@@ -11188,7 +11181,6 @@ __init static int tracer_alloc_buffers(void)
1118811181
free_cpumask_var(global_trace.tracing_cpumask);
1118911182
out_free_buffer_mask:
1119011183
free_cpumask_var(tracing_buffer_mask);
11191-
out:
1119211184
return ret;
1119311185
}
1119411186

0 commit comments

Comments
 (0)