Commit d3fddc35 authored by Yu Kuai's avatar Yu Kuai Committed by Arnaldo Carvalho de Melo

perf stat: Fix error return code in bperf__load()

Fix to return a negative error code from the error handling case instead
of 0, as done elsewhere in this function.

Committer notes:

Added the missing {} for the now multiline 'if' block, fixing this error:

    CC      /tmp/build/perf/util/bpf_counter.o
  util/bpf_counter.c: In function ‘bperf__load’:
  util/bpf_counter.c:523:9: error: this ‘if’ clause does not guard... [-Werror=misleading-indentation]
    523 |         if (evsel->bperf_leader_link_fd < 0 &&
        |         ^~
  util/bpf_counter.c:526:17: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
    526 |                 goto out;
        |                 ^~~~
  cc1: all warnings being treated as errors

Fixes: 7fac83aa ("perf stat: Introduce 'bperf' to share hardware PMCs with BPF")
Reported-by: default avatarHulk Robot <hulkci@huawei.com>
Signed-off-by: default avatarYu Kuai <yukuai3@huawei.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Andrii Nakryiko <andrii@kernel.org>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Song Liu <songliubraving@fb.com>
Cc: Yu Kuai <yukuai3@huawei.com>
Cc: Zhang Yi <yi.zhang@huawei.com>
Link: http://lore.kernel.org/lkml/20210517081254.1561564-1-yukuai3@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 4f2abe91
...@@ -521,9 +521,10 @@ static int bperf__load(struct evsel *evsel, struct target *target) ...@@ -521,9 +521,10 @@ static int bperf__load(struct evsel *evsel, struct target *target)
evsel->bperf_leader_link_fd = bpf_link_get_fd_by_id(entry.link_id); evsel->bperf_leader_link_fd = bpf_link_get_fd_by_id(entry.link_id);
if (evsel->bperf_leader_link_fd < 0 && if (evsel->bperf_leader_link_fd < 0 &&
bperf_reload_leader_program(evsel, attr_map_fd, &entry)) bperf_reload_leader_program(evsel, attr_map_fd, &entry)) {
err = -1;
goto out; goto out;
}
/* /*
* The bpf_link holds reference to the leader program, and the * The bpf_link holds reference to the leader program, and the
* leader program holds reference to the maps. Therefore, if * leader program holds reference to the maps. Therefore, if
...@@ -550,6 +551,7 @@ static int bperf__load(struct evsel *evsel, struct target *target) ...@@ -550,6 +551,7 @@ static int bperf__load(struct evsel *evsel, struct target *target)
/* Step 2: load the follower skeleton */ /* Step 2: load the follower skeleton */
evsel->follower_skel = bperf_follower_bpf__open(); evsel->follower_skel = bperf_follower_bpf__open();
if (!evsel->follower_skel) { if (!evsel->follower_skel) {
err = -1;
pr_err("Failed to open follower skeleton\n"); pr_err("Failed to open follower skeleton\n");
goto out; goto out;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment