perf evlist: Add thread_map__nr() helper
Introduce and use the thread_map__nr() function to protect a possible NULL pointer dereference and cleanup the code a bit. Signed-off-by: Namhyung Kim <namhyung@kernel.org> Cc: David Ahern <dsahern@gmail.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1362987798-24969-3-git-send-email-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:

committed by
Arnaldo Carvalho de Melo

parent
85397956de
commit
b3a319d528
@@ -249,7 +249,7 @@ static int read_counter_aggr(struct perf_evsel *counter)
|
||||
int i;
|
||||
|
||||
if (__perf_evsel__read(counter, perf_evsel__nr_cpus(counter),
|
||||
evsel_list->threads->nr, scale) < 0)
|
||||
thread_map__nr(evsel_list->threads), scale) < 0)
|
||||
return -1;
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
@@ -488,7 +488,7 @@ static int __run_perf_stat(int argc __maybe_unused, const char **argv)
|
||||
list_for_each_entry(counter, &evsel_list->entries, node) {
|
||||
read_counter_aggr(counter);
|
||||
perf_evsel__close_fd(counter, perf_evsel__nr_cpus(counter),
|
||||
evsel_list->threads->nr);
|
||||
thread_map__nr(evsel_list->threads));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user