diff options
author | Ingo Molnar <mingo@elte.hu> | 2009-07-01 06:37:06 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-07-01 06:49:48 -0400 |
commit | f37a291c527c954df4da568de718ebb36b8261c0 (patch) | |
tree | bb4863fbd185fbfef5f7d28cb4001d59d4123a2d /tools/perf/builtin-stat.c | |
parent | 88a69dfbc6ab1e3b51bba8c9103055e21089ebb9 (diff) |
perf_counter tools: Add more warnings and fix/annotate them
Enable -Wextra. This found a few real bugs plus a number
of signed/unsigned type mismatches/uncleanlinesses. It
also required a few annotations
All things considered it was still worth it so lets try with
this enabled for now.
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
LKML-Reference: <new-submission>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/builtin-stat.c')
-rw-r--r-- | tools/perf/builtin-stat.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 2e03524a1de0..095a90e012a1 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c | |||
@@ -64,7 +64,7 @@ static struct perf_counter_attr default_attrs[] = { | |||
64 | 64 | ||
65 | static int system_wide = 0; | 65 | static int system_wide = 0; |
66 | static int verbose = 0; | 66 | static int verbose = 0; |
67 | static int nr_cpus = 0; | 67 | static unsigned int nr_cpus = 0; |
68 | static int run_idx = 0; | 68 | static int run_idx = 0; |
69 | 69 | ||
70 | static int run_count = 1; | 70 | static int run_count = 1; |
@@ -108,7 +108,8 @@ static void create_perf_stat_counter(int counter, int pid) | |||
108 | PERF_FORMAT_TOTAL_TIME_RUNNING; | 108 | PERF_FORMAT_TOTAL_TIME_RUNNING; |
109 | 109 | ||
110 | if (system_wide) { | 110 | if (system_wide) { |
111 | int cpu; | 111 | unsigned int cpu; |
112 | |||
112 | for (cpu = 0; cpu < nr_cpus; cpu++) { | 113 | for (cpu = 0; cpu < nr_cpus; cpu++) { |
113 | fd[cpu][counter] = sys_perf_counter_open(attr, -1, cpu, -1, 0); | 114 | fd[cpu][counter] = sys_perf_counter_open(attr, -1, cpu, -1, 0); |
114 | if (fd[cpu][counter] < 0 && verbose) | 115 | if (fd[cpu][counter] < 0 && verbose) |
@@ -150,8 +151,8 @@ static inline int nsec_counter(int counter) | |||
150 | static void read_counter(int counter) | 151 | static void read_counter(int counter) |
151 | { | 152 | { |
152 | u64 *count, single_count[3]; | 153 | u64 *count, single_count[3]; |
153 | ssize_t res; | 154 | unsigned int cpu; |
154 | int cpu, nv; | 155 | size_t res, nv; |
155 | int scaled; | 156 | int scaled; |
156 | 157 | ||
157 | count = event_res[run_idx][counter]; | 158 | count = event_res[run_idx][counter]; |
@@ -165,6 +166,7 @@ static void read_counter(int counter) | |||
165 | 166 | ||
166 | res = read(fd[cpu][counter], single_count, nv * sizeof(u64)); | 167 | res = read(fd[cpu][counter], single_count, nv * sizeof(u64)); |
167 | assert(res == nv * sizeof(u64)); | 168 | assert(res == nv * sizeof(u64)); |
169 | |||
168 | close(fd[cpu][counter]); | 170 | close(fd[cpu][counter]); |
169 | fd[cpu][counter] = -1; | 171 | fd[cpu][counter] = -1; |
170 | 172 | ||
@@ -200,7 +202,7 @@ static void read_counter(int counter) | |||
200 | runtime_cycles[run_idx] = count[0]; | 202 | runtime_cycles[run_idx] = count[0]; |
201 | } | 203 | } |
202 | 204 | ||
203 | static int run_perf_stat(int argc, const char **argv) | 205 | static int run_perf_stat(int argc __used, const char **argv) |
204 | { | 206 | { |
205 | unsigned long long t0, t1; | 207 | unsigned long long t0, t1; |
206 | int status = 0; | 208 | int status = 0; |
@@ -390,7 +392,7 @@ static void calc_avg(void) | |||
390 | event_res_avg[j]+1, event_res[i][j]+1); | 392 | event_res_avg[j]+1, event_res[i][j]+1); |
391 | update_avg("counter/2", j, | 393 | update_avg("counter/2", j, |
392 | event_res_avg[j]+2, event_res[i][j]+2); | 394 | event_res_avg[j]+2, event_res[i][j]+2); |
393 | if (event_scaled[i][j] != -1) | 395 | if (event_scaled[i][j] != (u64)-1) |
394 | update_avg("scaled", j, | 396 | update_avg("scaled", j, |
395 | event_scaled_avg + j, event_scaled[i]+j); | 397 | event_scaled_avg + j, event_scaled[i]+j); |
396 | else | 398 | else |
@@ -510,7 +512,7 @@ static const struct option options[] = { | |||
510 | OPT_END() | 512 | OPT_END() |
511 | }; | 513 | }; |
512 | 514 | ||
513 | int cmd_stat(int argc, const char **argv, const char *prefix) | 515 | int cmd_stat(int argc, const char **argv, const char *prefix __used) |
514 | { | 516 | { |
515 | int status; | 517 | int status; |
516 | 518 | ||
@@ -528,7 +530,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix) | |||
528 | 530 | ||
529 | nr_cpus = sysconf(_SC_NPROCESSORS_ONLN); | 531 | nr_cpus = sysconf(_SC_NPROCESSORS_ONLN); |
530 | assert(nr_cpus <= MAX_NR_CPUS); | 532 | assert(nr_cpus <= MAX_NR_CPUS); |
531 | assert(nr_cpus >= 0); | 533 | assert((int)nr_cpus >= 0); |
532 | 534 | ||
533 | /* | 535 | /* |
534 | * We dont want to block the signals - that would cause | 536 | * We dont want to block the signals - that would cause |