Skip to content

Commit

Permalink
perf probe: Cleanup find_perf_probe_point_from_map to reduce redundancy
Browse files Browse the repository at this point in the history
In find_perf_probe_point_from_map(), the 'ret' variable is initialized
with -ENOENT but overwritten by the return code of
kernel_get_symbol_address_by_name(), and after that it is re-initialized
with -ENOENT again.

Setting ret=-ENOENT twice looks a bit redundant. This avoids the
overwriting and just returns -ENOENT if some error happens to simplify
the code.

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Cc: Zefan Li <lizefan@huawei.com>
Link: http://lkml.kernel.org/n/tip-ufp1zgbktzmttcputozneomd@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Masami Hiramatsu authored and Arnaldo Carvalho de Melo committed Nov 6, 2015
1 parent 62ec9b3 commit 0a62f68
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions tools/perf/util/probe-event.c
Original file line number Diff line number Diff line change
Expand Up @@ -1895,9 +1895,8 @@ static int find_perf_probe_point_from_map(struct probe_trace_point *tp,
sym = map__find_symbol(map, addr, NULL);
} else {
if (tp->symbol && !addr) {
ret = kernel_get_symbol_address_by_name(tp->symbol,
&addr, true, false);
if (ret < 0)
if (kernel_get_symbol_address_by_name(tp->symbol,
&addr, true, false) < 0)
goto out;
}
if (addr) {
Expand All @@ -1906,8 +1905,6 @@ static int find_perf_probe_point_from_map(struct probe_trace_point *tp,
}
}

/* ret may has be overwritten so reset it */
ret = -ENOENT;
if (!sym)
goto out;

Expand Down

0 comments on commit 0a62f68

Please sign in to comment.