diff options
author | Namhyung Kim <namhyung.kim@lge.com> | 2013-03-11 03:43:14 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-03-15 12:06:02 -0400 |
commit | b3a319d528fd57ef600731ee1b84d00b7204881d (patch) | |
tree | fadbcc4a692d5a4e841af9823c527eca7c5dc7dc /tools/perf/builtin-stat.c | |
parent | 85397956de304106e2fdace2db8f69ab4e966bc5 (diff) |
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>
Diffstat (limited to 'tools/perf/builtin-stat.c')
-rw-r--r-- | tools/perf/builtin-stat.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 020329dca005..20ffaf98782e 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c | |||
@@ -249,7 +249,7 @@ static int read_counter_aggr(struct perf_evsel *counter) | |||
249 | int i; | 249 | int i; |
250 | 250 | ||
251 | if (__perf_evsel__read(counter, perf_evsel__nr_cpus(counter), | 251 | if (__perf_evsel__read(counter, perf_evsel__nr_cpus(counter), |
252 | evsel_list->threads->nr, scale) < 0) | 252 | thread_map__nr(evsel_list->threads), scale) < 0) |
253 | return -1; | 253 | return -1; |
254 | 254 | ||
255 | for (i = 0; i < 3; i++) | 255 | for (i = 0; i < 3; i++) |
@@ -488,7 +488,7 @@ static int __run_perf_stat(int argc __maybe_unused, const char **argv) | |||
488 | list_for_each_entry(counter, &evsel_list->entries, node) { | 488 | list_for_each_entry(counter, &evsel_list->entries, node) { |
489 | read_counter_aggr(counter); | 489 | read_counter_aggr(counter); |
490 | perf_evsel__close_fd(counter, perf_evsel__nr_cpus(counter), | 490 | perf_evsel__close_fd(counter, perf_evsel__nr_cpus(counter), |
491 | evsel_list->threads->nr); | 491 | thread_map__nr(evsel_list->threads)); |
492 | } | 492 | } |
493 | } | 493 | } |
494 | 494 | ||