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 | |
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')
-rw-r--r-- | tools/perf/Makefile | 2 | ||||
-rw-r--r-- | tools/perf/builtin-annotate.c | 12 | ||||
-rw-r--r-- | tools/perf/builtin-help.c | 6 | ||||
-rw-r--r-- | tools/perf/builtin-list.c | 2 | ||||
-rw-r--r-- | tools/perf/builtin-record.c | 4 | ||||
-rw-r--r-- | tools/perf/builtin-report.c | 22 | ||||
-rw-r--r-- | tools/perf/builtin-stat.c | 18 | ||||
-rw-r--r-- | tools/perf/builtin-top.c | 8 | ||||
-rw-r--r-- | tools/perf/perf.c | 5 | ||||
-rw-r--r-- | tools/perf/perf.h | 2 | ||||
-rw-r--r-- | tools/perf/util/alias.c | 2 | ||||
-rw-r--r-- | tools/perf/util/cache.h | 1 | ||||
-rw-r--r-- | tools/perf/util/callchain.c | 15 | ||||
-rw-r--r-- | tools/perf/util/callchain.h | 10 | ||||
-rw-r--r-- | tools/perf/util/color.c | 10 | ||||
-rw-r--r-- | tools/perf/util/config.c | 18 | ||||
-rw-r--r-- | tools/perf/util/exec_cmd.c | 5 | ||||
-rw-r--r-- | tools/perf/util/help.c | 26 | ||||
-rw-r--r-- | tools/perf/util/help.h | 6 | ||||
-rw-r--r-- | tools/perf/util/parse-events.c | 2 | ||||
-rw-r--r-- | tools/perf/util/parse-options.c | 2 | ||||
-rw-r--r-- | tools/perf/util/parse-options.h | 25 | ||||
-rw-r--r-- | tools/perf/util/quote.c | 46 | ||||
-rw-r--r-- | tools/perf/util/quote.h | 2 | ||||
-rw-r--r-- | tools/perf/util/strbuf.c | 13 | ||||
-rw-r--r-- | tools/perf/util/strbuf.h | 10 | ||||
-rw-r--r-- | tools/perf/util/wrapper.c | 5 |
27 files changed, 151 insertions, 128 deletions
diff --git a/tools/perf/Makefile b/tools/perf/Makefile index f572c90f610e..eddf076b19d7 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile | |||
@@ -164,7 +164,7 @@ endif | |||
164 | 164 | ||
165 | # CFLAGS and LDFLAGS are for the users to override from the command line. | 165 | # CFLAGS and LDFLAGS are for the users to override from the command line. |
166 | 166 | ||
167 | CFLAGS = $(M64) -ggdb3 -Wall -Wstrict-prototypes -Wmissing-declarations -Wmissing-prototypes -std=gnu99 -Wdeclaration-after-statement -Werror -O6 | 167 | CFLAGS = $(M64) -ggdb3 -Wall -Wextra -Wstrict-prototypes -Wmissing-declarations -Wmissing-prototypes -std=gnu99 -Wdeclaration-after-statement -Werror -O6 |
168 | LDFLAGS = -lpthread -lrt -lelf -lm | 168 | LDFLAGS = -lpthread -lrt -lelf -lm |
169 | ALL_CFLAGS = $(CFLAGS) | 169 | ALL_CFLAGS = $(CFLAGS) |
170 | ALL_LDFLAGS = $(LDFLAGS) | 170 | ALL_LDFLAGS = $(LDFLAGS) |
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index 722c0f54e549..6cba70daf121 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c | |||
@@ -160,7 +160,7 @@ static void dsos__fprintf(FILE *fp) | |||
160 | 160 | ||
161 | static struct symbol *vdso__find_symbol(struct dso *dso, u64 ip) | 161 | static struct symbol *vdso__find_symbol(struct dso *dso, u64 ip) |
162 | { | 162 | { |
163 | return dso__find_symbol(kernel_dso, ip); | 163 | return dso__find_symbol(dso, ip); |
164 | } | 164 | } |
165 | 165 | ||
166 | static int load_kernel(void) | 166 | static int load_kernel(void) |
@@ -203,7 +203,7 @@ static u64 map__map_ip(struct map *map, u64 ip) | |||
203 | return ip - map->start + map->pgoff; | 203 | return ip - map->start + map->pgoff; |
204 | } | 204 | } |
205 | 205 | ||
206 | static u64 vdso__map_ip(struct map *map, u64 ip) | 206 | static u64 vdso__map_ip(struct map *map __used, u64 ip) |
207 | { | 207 | { |
208 | return ip; | 208 | return ip; |
209 | } | 209 | } |
@@ -600,7 +600,7 @@ static LIST_HEAD(hist_entry__sort_list); | |||
600 | 600 | ||
601 | static int sort_dimension__add(char *tok) | 601 | static int sort_dimension__add(char *tok) |
602 | { | 602 | { |
603 | int i; | 603 | unsigned int i; |
604 | 604 | ||
605 | for (i = 0; i < ARRAY_SIZE(sort_dimensions); i++) { | 605 | for (i = 0; i < ARRAY_SIZE(sort_dimensions); i++) { |
606 | struct sort_dimension *sd = &sort_dimensions[i]; | 606 | struct sort_dimension *sd = &sort_dimensions[i]; |
@@ -1069,7 +1069,7 @@ parse_line(FILE *file, struct symbol *sym, u64 start, u64 len) | |||
1069 | static const char *prev_color; | 1069 | static const char *prev_color; |
1070 | unsigned int offset; | 1070 | unsigned int offset; |
1071 | size_t line_len; | 1071 | size_t line_len; |
1072 | u64 line_ip; | 1072 | s64 line_ip; |
1073 | int ret; | 1073 | int ret; |
1074 | char *c; | 1074 | char *c; |
1075 | 1075 | ||
@@ -1428,7 +1428,7 @@ more: | |||
1428 | 1428 | ||
1429 | head += size; | 1429 | head += size; |
1430 | 1430 | ||
1431 | if (offset + head < stat.st_size) | 1431 | if (offset + head < (unsigned long)stat.st_size) |
1432 | goto more; | 1432 | goto more; |
1433 | 1433 | ||
1434 | rc = EXIT_SUCCESS; | 1434 | rc = EXIT_SUCCESS; |
@@ -1492,7 +1492,7 @@ static void setup_sorting(void) | |||
1492 | free(str); | 1492 | free(str); |
1493 | } | 1493 | } |
1494 | 1494 | ||
1495 | int cmd_annotate(int argc, const char **argv, const char *prefix) | 1495 | int cmd_annotate(int argc, const char **argv, const char *prefix __used) |
1496 | { | 1496 | { |
1497 | symbol__init(); | 1497 | symbol__init(); |
1498 | 1498 | ||
diff --git a/tools/perf/builtin-help.c b/tools/perf/builtin-help.c index 0f32dc3f3c4c..2599d86a733b 100644 --- a/tools/perf/builtin-help.c +++ b/tools/perf/builtin-help.c | |||
@@ -3,6 +3,7 @@ | |||
3 | * | 3 | * |
4 | * Builtin help command | 4 | * Builtin help command |
5 | */ | 5 | */ |
6 | #include "perf.h" | ||
6 | #include "util/cache.h" | 7 | #include "util/cache.h" |
7 | #include "builtin.h" | 8 | #include "builtin.h" |
8 | #include "util/exec_cmd.h" | 9 | #include "util/exec_cmd.h" |
@@ -277,7 +278,7 @@ static struct cmdnames main_cmds, other_cmds; | |||
277 | 278 | ||
278 | void list_common_cmds_help(void) | 279 | void list_common_cmds_help(void) |
279 | { | 280 | { |
280 | int i, longest = 0; | 281 | unsigned int i, longest = 0; |
281 | 282 | ||
282 | for (i = 0; i < ARRAY_SIZE(common_cmds); i++) { | 283 | for (i = 0; i < ARRAY_SIZE(common_cmds); i++) { |
283 | if (longest < strlen(common_cmds[i].name)) | 284 | if (longest < strlen(common_cmds[i].name)) |
@@ -415,9 +416,10 @@ static void show_html_page(const char *perf_cmd) | |||
415 | open_html(page_path.buf); | 416 | open_html(page_path.buf); |
416 | } | 417 | } |
417 | 418 | ||
418 | int cmd_help(int argc, const char **argv, const char *prefix) | 419 | int cmd_help(int argc, const char **argv, const char *prefix __used) |
419 | { | 420 | { |
420 | const char *alias; | 421 | const char *alias; |
422 | |||
421 | load_command_list("perf-", &main_cmds, &other_cmds); | 423 | load_command_list("perf-", &main_cmds, &other_cmds); |
422 | 424 | ||
423 | perf_config(perf_help_config, NULL); | 425 | perf_config(perf_help_config, NULL); |
diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c index fe60e37c96ef..f990fa8a35c9 100644 --- a/tools/perf/builtin-list.c +++ b/tools/perf/builtin-list.c | |||
@@ -13,7 +13,7 @@ | |||
13 | #include "util/parse-options.h" | 13 | #include "util/parse-options.h" |
14 | #include "util/parse-events.h" | 14 | #include "util/parse-events.h" |
15 | 15 | ||
16 | int cmd_list(int argc, const char **argv, const char *prefix) | 16 | int cmd_list(int argc __used, const char **argv __used, const char *prefix __used) |
17 | { | 17 | { |
18 | print_events(); | 18 | print_events(); |
19 | return 0; | 19 | return 0; |
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index d18546f37d7c..4ef78a5e6f32 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
@@ -294,7 +294,7 @@ static void pid_synthesize_mmap_samples(pid_t pid) | |||
294 | while (1) { | 294 | while (1) { |
295 | char bf[BUFSIZ], *pbf = bf; | 295 | char bf[BUFSIZ], *pbf = bf; |
296 | struct mmap_event mmap_ev = { | 296 | struct mmap_event mmap_ev = { |
297 | .header.type = PERF_EVENT_MMAP, | 297 | .header = { .type = PERF_EVENT_MMAP }, |
298 | }; | 298 | }; |
299 | int n; | 299 | int n; |
300 | size_t size; | 300 | size_t size; |
@@ -650,7 +650,7 @@ static const struct option options[] = { | |||
650 | OPT_END() | 650 | OPT_END() |
651 | }; | 651 | }; |
652 | 652 | ||
653 | int cmd_record(int argc, const char **argv, const char *prefix) | 653 | int cmd_record(int argc, const char **argv, const char *prefix __used) |
654 | { | 654 | { |
655 | int counter; | 655 | int counter; |
656 | 656 | ||
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 7d2b49adcdc5..007363db3b16 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c | |||
@@ -177,7 +177,7 @@ static void dsos__fprintf(FILE *fp) | |||
177 | 177 | ||
178 | static struct symbol *vdso__find_symbol(struct dso *dso, u64 ip) | 178 | static struct symbol *vdso__find_symbol(struct dso *dso, u64 ip) |
179 | { | 179 | { |
180 | return dso__find_symbol(kernel_dso, ip); | 180 | return dso__find_symbol(dso, ip); |
181 | } | 181 | } |
182 | 182 | ||
183 | static int load_kernel(void) | 183 | static int load_kernel(void) |
@@ -239,7 +239,7 @@ static u64 map__map_ip(struct map *map, u64 ip) | |||
239 | return ip - map->start + map->pgoff; | 239 | return ip - map->start + map->pgoff; |
240 | } | 240 | } |
241 | 241 | ||
242 | static u64 vdso__map_ip(struct map *map, u64 ip) | 242 | static u64 vdso__map_ip(struct map *map __used, u64 ip) |
243 | { | 243 | { |
244 | return ip; | 244 | return ip; |
245 | } | 245 | } |
@@ -712,7 +712,7 @@ static LIST_HEAD(hist_entry__sort_list); | |||
712 | 712 | ||
713 | static int sort_dimension__add(char *tok) | 713 | static int sort_dimension__add(char *tok) |
714 | { | 714 | { |
715 | int i; | 715 | unsigned int i; |
716 | 716 | ||
717 | for (i = 0; i < ARRAY_SIZE(sort_dimensions); i++) { | 717 | for (i = 0; i < ARRAY_SIZE(sort_dimensions); i++) { |
718 | struct sort_dimension *sd = &sort_dimensions[i]; | 718 | struct sort_dimension *sd = &sort_dimensions[i]; |
@@ -801,7 +801,7 @@ callchain__fprintf(FILE *fp, struct callchain_node *self, u64 total_samples) | |||
801 | ret += fprintf(fp, " %s\n", chain->sym->name); | 801 | ret += fprintf(fp, " %s\n", chain->sym->name); |
802 | else | 802 | else |
803 | ret += fprintf(fp, " %p\n", | 803 | ret += fprintf(fp, " %p\n", |
804 | (void *)chain->ip); | 804 | (void *)(long)chain->ip); |
805 | } | 805 | } |
806 | 806 | ||
807 | return ret; | 807 | return ret; |
@@ -938,12 +938,12 @@ static int call__match(struct symbol *sym) | |||
938 | } | 938 | } |
939 | 939 | ||
940 | static struct symbol ** | 940 | static struct symbol ** |
941 | resolve_callchain(struct thread *thread, struct map *map, | 941 | resolve_callchain(struct thread *thread, struct map *map __used, |
942 | struct ip_callchain *chain, struct hist_entry *entry) | 942 | struct ip_callchain *chain, struct hist_entry *entry) |
943 | { | 943 | { |
944 | int i; | ||
945 | struct symbol **syms; | ||
946 | u64 context = PERF_CONTEXT_MAX; | 944 | u64 context = PERF_CONTEXT_MAX; |
945 | struct symbol **syms; | ||
946 | unsigned int i; | ||
947 | 947 | ||
948 | if (callchain) { | 948 | if (callchain) { |
949 | syms = calloc(chain->nr, sizeof(*syms)); | 949 | syms = calloc(chain->nr, sizeof(*syms)); |
@@ -1183,7 +1183,7 @@ static size_t output__fprintf(FILE *fp, u64 total_samples) | |||
1183 | 1183 | ||
1184 | fprintf(fp, "# ........"); | 1184 | fprintf(fp, "# ........"); |
1185 | list_for_each_entry(se, &hist_entry__sort_list, list) { | 1185 | list_for_each_entry(se, &hist_entry__sort_list, list) { |
1186 | int i; | 1186 | unsigned int i; |
1187 | 1187 | ||
1188 | if (exclude_other && (se == &sort_parent)) | 1188 | if (exclude_other && (se == &sort_parent)) |
1189 | continue; | 1189 | continue; |
@@ -1271,7 +1271,7 @@ process_sample_event(event_t *event, unsigned long offset, unsigned long head) | |||
1271 | (long long)period); | 1271 | (long long)period); |
1272 | 1272 | ||
1273 | if (sample_type & PERF_SAMPLE_CALLCHAIN) { | 1273 | if (sample_type & PERF_SAMPLE_CALLCHAIN) { |
1274 | int i; | 1274 | unsigned int i; |
1275 | 1275 | ||
1276 | chain = (void *)more_data; | 1276 | chain = (void *)more_data; |
1277 | 1277 | ||
@@ -1667,7 +1667,7 @@ more: | |||
1667 | if (offset + head >= header->data_offset + header->data_size) | 1667 | if (offset + head >= header->data_offset + header->data_size) |
1668 | goto done; | 1668 | goto done; |
1669 | 1669 | ||
1670 | if (offset + head < stat.st_size) | 1670 | if (offset + head < (unsigned long)stat.st_size) |
1671 | goto more; | 1671 | goto more; |
1672 | 1672 | ||
1673 | done: | 1673 | done: |
@@ -1756,7 +1756,7 @@ static void setup_list(struct strlist **list, const char *list_str, | |||
1756 | } | 1756 | } |
1757 | } | 1757 | } |
1758 | 1758 | ||
1759 | int cmd_report(int argc, const char **argv, const char *prefix) | 1759 | int cmd_report(int argc, const char **argv, const char *prefix __used) |
1760 | { | 1760 | { |
1761 | symbol__init(); | 1761 | symbol__init(); |
1762 | 1762 | ||
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 |
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 0506cd6e04cc..5f5e7df8302d 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
@@ -269,7 +269,7 @@ static void print_sym_table(void) | |||
269 | } | 269 | } |
270 | } | 270 | } |
271 | 271 | ||
272 | static void *display_thread(void *arg) | 272 | static void *display_thread(void *arg __used) |
273 | { | 273 | { |
274 | struct pollfd stdin_poll = { .fd = 0, .events = POLLIN }; | 274 | struct pollfd stdin_poll = { .fd = 0, .events = POLLIN }; |
275 | int delay_msecs = delay_secs * 1000; | 275 | int delay_msecs = delay_secs * 1000; |
@@ -287,7 +287,7 @@ static void *display_thread(void *arg) | |||
287 | } | 287 | } |
288 | 288 | ||
289 | /* Tag samples to be skipped. */ | 289 | /* Tag samples to be skipped. */ |
290 | char *skip_symbols[] = { | 290 | static const char *skip_symbols[] = { |
291 | "default_idle", | 291 | "default_idle", |
292 | "cpu_idle", | 292 | "cpu_idle", |
293 | "enter_idle", | 293 | "enter_idle", |
@@ -426,7 +426,7 @@ static void process_event(u64 ip, int counter, int user) | |||
426 | struct mmap_data { | 426 | struct mmap_data { |
427 | int counter; | 427 | int counter; |
428 | void *base; | 428 | void *base; |
429 | unsigned int mask; | 429 | int mask; |
430 | unsigned int prev; | 430 | unsigned int prev; |
431 | }; | 431 | }; |
432 | 432 | ||
@@ -705,7 +705,7 @@ static const struct option options[] = { | |||
705 | OPT_END() | 705 | OPT_END() |
706 | }; | 706 | }; |
707 | 707 | ||
708 | int cmd_top(int argc, const char **argv, const char *prefix) | 708 | int cmd_top(int argc, const char **argv, const char *prefix __used) |
709 | { | 709 | { |
710 | int counter; | 710 | int counter; |
711 | 711 | ||
diff --git a/tools/perf/perf.c b/tools/perf/perf.c index 4eb725933703..c5656784c61d 100644 --- a/tools/perf/perf.c +++ b/tools/perf/perf.c | |||
@@ -229,9 +229,6 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv) | |||
229 | use_pager = 1; | 229 | use_pager = 1; |
230 | commit_pager_choice(); | 230 | commit_pager_choice(); |
231 | 231 | ||
232 | if (p->option & NEED_WORK_TREE) | ||
233 | /* setup_work_tree() */; | ||
234 | |||
235 | status = p->fn(argc, argv, prefix); | 232 | status = p->fn(argc, argv, prefix); |
236 | if (status) | 233 | if (status) |
237 | return status & 0xff; | 234 | return status & 0xff; |
@@ -266,7 +263,7 @@ static void handle_internal_command(int argc, const char **argv) | |||
266 | { "annotate", cmd_annotate, 0 }, | 263 | { "annotate", cmd_annotate, 0 }, |
267 | { "version", cmd_version, 0 }, | 264 | { "version", cmd_version, 0 }, |
268 | }; | 265 | }; |
269 | int i; | 266 | unsigned int i; |
270 | static const char ext[] = STRIP_EXTENSION; | 267 | static const char ext[] = STRIP_EXTENSION; |
271 | 268 | ||
272 | if (sizeof(ext) > 1) { | 269 | if (sizeof(ext) > 1) { |
diff --git a/tools/perf/perf.h b/tools/perf/perf.h index ce394192c85a..27887c916439 100644 --- a/tools/perf/perf.h +++ b/tools/perf/perf.h | |||
@@ -52,6 +52,8 @@ static inline unsigned long long rdclock(void) | |||
52 | #define __user | 52 | #define __user |
53 | #define asmlinkage | 53 | #define asmlinkage |
54 | 54 | ||
55 | #define __used __attribute__((__unused__)) | ||
56 | |||
55 | #define unlikely(x) __builtin_expect(!!(x), 0) | 57 | #define unlikely(x) __builtin_expect(!!(x), 0) |
56 | #define min(x, y) ({ \ | 58 | #define min(x, y) ({ \ |
57 | typeof(x) _min1 = (x); \ | 59 | typeof(x) _min1 = (x); \ |
diff --git a/tools/perf/util/alias.c b/tools/perf/util/alias.c index 9b3dd2b428df..b8144e80bb1e 100644 --- a/tools/perf/util/alias.c +++ b/tools/perf/util/alias.c | |||
@@ -3,7 +3,7 @@ | |||
3 | static const char *alias_key; | 3 | static const char *alias_key; |
4 | static char *alias_val; | 4 | static char *alias_val; |
5 | 5 | ||
6 | static int alias_lookup_cb(const char *k, const char *v, void *cb) | 6 | static int alias_lookup_cb(const char *k, const char *v, void *cb __used) |
7 | { | 7 | { |
8 | if (!prefixcmp(k, "alias.") && !strcmp(k+6, alias_key)) { | 8 | if (!prefixcmp(k, "alias.") && !strcmp(k+6, alias_key)) { |
9 | if (!v) | 9 | if (!v) |
diff --git a/tools/perf/util/cache.h b/tools/perf/util/cache.h index 393d6146d13b..161d5f413e28 100644 --- a/tools/perf/util/cache.h +++ b/tools/perf/util/cache.h | |||
@@ -3,6 +3,7 @@ | |||
3 | 3 | ||
4 | #include "util.h" | 4 | #include "util.h" |
5 | #include "strbuf.h" | 5 | #include "strbuf.h" |
6 | #include "../perf.h" | ||
6 | 7 | ||
7 | #define PERF_DIR_ENVIRONMENT "PERF_DIR" | 8 | #define PERF_DIR_ENVIRONMENT "PERF_DIR" |
8 | #define PERF_WORK_TREE_ENVIRONMENT "PERF_WORK_TREE" | 9 | #define PERF_WORK_TREE_ENVIRONMENT "PERF_WORK_TREE" |
diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c index 440db12c6359..3dceabd9b5ef 100644 --- a/tools/perf/util/callchain.c +++ b/tools/perf/util/callchain.c | |||
@@ -92,7 +92,7 @@ static void | |||
92 | fill_node(struct callchain_node *node, struct ip_callchain *chain, | 92 | fill_node(struct callchain_node *node, struct ip_callchain *chain, |
93 | int start, struct symbol **syms) | 93 | int start, struct symbol **syms) |
94 | { | 94 | { |
95 | int i; | 95 | unsigned int i; |
96 | 96 | ||
97 | for (i = start; i < chain->nr; i++) { | 97 | for (i = start; i < chain->nr; i++) { |
98 | struct callchain_list *call; | 98 | struct callchain_list *call; |
@@ -135,7 +135,7 @@ split_add_child(struct callchain_node *parent, struct ip_callchain *chain, | |||
135 | { | 135 | { |
136 | struct callchain_node *new; | 136 | struct callchain_node *new; |
137 | struct list_head *old_tail; | 137 | struct list_head *old_tail; |
138 | int idx_total = idx_parents + idx_local; | 138 | unsigned int idx_total = idx_parents + idx_local; |
139 | 139 | ||
140 | /* split */ | 140 | /* split */ |
141 | new = create_child(parent, true); | 141 | new = create_child(parent, true); |
@@ -164,17 +164,18 @@ split_add_child(struct callchain_node *parent, struct ip_callchain *chain, | |||
164 | 164 | ||
165 | static int | 165 | static int |
166 | __append_chain(struct callchain_node *root, struct ip_callchain *chain, | 166 | __append_chain(struct callchain_node *root, struct ip_callchain *chain, |
167 | int start, struct symbol **syms); | 167 | unsigned int start, struct symbol **syms); |
168 | 168 | ||
169 | static void | 169 | static void |
170 | __append_chain_children(struct callchain_node *root, struct ip_callchain *chain, | 170 | __append_chain_children(struct callchain_node *root, struct ip_callchain *chain, |
171 | struct symbol **syms, int start) | 171 | struct symbol **syms, unsigned int start) |
172 | { | 172 | { |
173 | struct callchain_node *rnode; | 173 | struct callchain_node *rnode; |
174 | 174 | ||
175 | /* lookup in childrens */ | 175 | /* lookup in childrens */ |
176 | list_for_each_entry(rnode, &root->children, brothers) { | 176 | list_for_each_entry(rnode, &root->children, brothers) { |
177 | int ret = __append_chain(rnode, chain, start, syms); | 177 | unsigned int ret = __append_chain(rnode, chain, start, syms); |
178 | |||
178 | if (!ret) | 179 | if (!ret) |
179 | return; | 180 | return; |
180 | } | 181 | } |
@@ -184,10 +185,10 @@ __append_chain_children(struct callchain_node *root, struct ip_callchain *chain, | |||
184 | 185 | ||
185 | static int | 186 | static int |
186 | __append_chain(struct callchain_node *root, struct ip_callchain *chain, | 187 | __append_chain(struct callchain_node *root, struct ip_callchain *chain, |
187 | int start, struct symbol **syms) | 188 | unsigned int start, struct symbol **syms) |
188 | { | 189 | { |
189 | struct callchain_list *cnode; | 190 | struct callchain_list *cnode; |
190 | int i = start; | 191 | unsigned int i = start; |
191 | bool found = false; | 192 | bool found = false; |
192 | 193 | ||
193 | /* | 194 | /* |
diff --git a/tools/perf/util/callchain.h b/tools/perf/util/callchain.h index c942daa712e6..251d99ecd225 100644 --- a/tools/perf/util/callchain.h +++ b/tools/perf/util/callchain.h | |||
@@ -10,15 +10,15 @@ | |||
10 | struct callchain_node { | 10 | struct callchain_node { |
11 | struct callchain_node *parent; | 11 | struct callchain_node *parent; |
12 | struct list_head brothers; | 12 | struct list_head brothers; |
13 | struct list_head children; | 13 | struct list_head children; |
14 | struct list_head val; | 14 | struct list_head val; |
15 | struct rb_node rb_node; | 15 | struct rb_node rb_node; |
16 | int val_nr; | 16 | unsigned int val_nr; |
17 | int hit; | 17 | u64 hit; |
18 | }; | 18 | }; |
19 | 19 | ||
20 | struct callchain_list { | 20 | struct callchain_list { |
21 | unsigned long ip; | 21 | u64 ip; |
22 | struct symbol *sym; | 22 | struct symbol *sym; |
23 | struct list_head list; | 23 | struct list_head list; |
24 | }; | 24 | }; |
diff --git a/tools/perf/util/color.c b/tools/perf/util/color.c index 9a8c20ccc53e..26f82318b86b 100644 --- a/tools/perf/util/color.c +++ b/tools/perf/util/color.c | |||
@@ -11,7 +11,8 @@ static int parse_color(const char *name, int len) | |||
11 | }; | 11 | }; |
12 | char *end; | 12 | char *end; |
13 | int i; | 13 | int i; |
14 | for (i = 0; i < ARRAY_SIZE(color_names); i++) { | 14 | |
15 | for (i = 0; i < (int)ARRAY_SIZE(color_names); i++) { | ||
15 | const char *str = color_names[i]; | 16 | const char *str = color_names[i]; |
16 | if (!strncasecmp(name, str, len) && !str[len]) | 17 | if (!strncasecmp(name, str, len) && !str[len]) |
17 | return i - 1; | 18 | return i - 1; |
@@ -28,7 +29,8 @@ static int parse_attr(const char *name, int len) | |||
28 | static const char * const attr_names[] = { | 29 | static const char * const attr_names[] = { |
29 | "bold", "dim", "ul", "blink", "reverse" | 30 | "bold", "dim", "ul", "blink", "reverse" |
30 | }; | 31 | }; |
31 | int i; | 32 | unsigned int i; |
33 | |||
32 | for (i = 0; i < ARRAY_SIZE(attr_names); i++) { | 34 | for (i = 0; i < ARRAY_SIZE(attr_names); i++) { |
33 | const char *str = attr_names[i]; | 35 | const char *str = attr_names[i]; |
34 | if (!strncasecmp(name, str, len) && !str[len]) | 36 | if (!strncasecmp(name, str, len) && !str[len]) |
@@ -222,10 +224,12 @@ int color_fwrite_lines(FILE *fp, const char *color, | |||
222 | { | 224 | { |
223 | if (!*color) | 225 | if (!*color) |
224 | return fwrite(buf, count, 1, fp) != 1; | 226 | return fwrite(buf, count, 1, fp) != 1; |
227 | |||
225 | while (count) { | 228 | while (count) { |
226 | char *p = memchr(buf, '\n', count); | 229 | char *p = memchr(buf, '\n', count); |
230 | |||
227 | if (p != buf && (fputs(color, fp) < 0 || | 231 | if (p != buf && (fputs(color, fp) < 0 || |
228 | fwrite(buf, p ? p - buf : count, 1, fp) != 1 || | 232 | fwrite(buf, p ? (size_t)(p - buf) : count, 1, fp) != 1 || |
229 | fputs(PERF_COLOR_RESET, fp) < 0)) | 233 | fputs(PERF_COLOR_RESET, fp) < 0)) |
230 | return -1; | 234 | return -1; |
231 | if (!p) | 235 | if (!p) |
diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c index 3dd13faa6a27..780df541006d 100644 --- a/tools/perf/util/config.c +++ b/tools/perf/util/config.c | |||
@@ -47,10 +47,12 @@ static int get_next_char(void) | |||
47 | static char *parse_value(void) | 47 | static char *parse_value(void) |
48 | { | 48 | { |
49 | static char value[1024]; | 49 | static char value[1024]; |
50 | int quote = 0, comment = 0, len = 0, space = 0; | 50 | int quote = 0, comment = 0, space = 0; |
51 | size_t len = 0; | ||
51 | 52 | ||
52 | for (;;) { | 53 | for (;;) { |
53 | int c = get_next_char(); | 54 | int c = get_next_char(); |
55 | |||
54 | if (len >= sizeof(value) - 1) | 56 | if (len >= sizeof(value) - 1) |
55 | return NULL; | 57 | return NULL; |
56 | if (c == '\n') { | 58 | if (c == '\n') { |
@@ -353,13 +355,13 @@ int perf_config_string(const char **dest, const char *var, const char *value) | |||
353 | return 0; | 355 | return 0; |
354 | } | 356 | } |
355 | 357 | ||
356 | static int perf_default_core_config(const char *var, const char *value) | 358 | static int perf_default_core_config(const char *var __used, const char *value __used) |
357 | { | 359 | { |
358 | /* Add other config variables here and to Documentation/config.txt. */ | 360 | /* Add other config variables here and to Documentation/config.txt. */ |
359 | return 0; | 361 | return 0; |
360 | } | 362 | } |
361 | 363 | ||
362 | int perf_default_config(const char *var, const char *value, void *dummy) | 364 | int perf_default_config(const char *var, const char *value, void *dummy __used) |
363 | { | 365 | { |
364 | if (!prefixcmp(var, "core.")) | 366 | if (!prefixcmp(var, "core.")) |
365 | return perf_default_core_config(var, value); | 367 | return perf_default_core_config(var, value); |
@@ -471,10 +473,10 @@ static int matches(const char* key, const char* value) | |||
471 | !regexec(store.value_regex, value, 0, NULL, 0))); | 473 | !regexec(store.value_regex, value, 0, NULL, 0))); |
472 | } | 474 | } |
473 | 475 | ||
474 | static int store_aux(const char* key, const char* value, void *cb) | 476 | static int store_aux(const char* key, const char* value, void *cb __used) |
475 | { | 477 | { |
478 | int section_len; | ||
476 | const char *ep; | 479 | const char *ep; |
477 | size_t section_len; | ||
478 | 480 | ||
479 | switch (store.state) { | 481 | switch (store.state) { |
480 | case KEY_SEEN: | 482 | case KEY_SEEN: |
@@ -551,7 +553,7 @@ static int store_write_section(int fd, const char* key) | |||
551 | strbuf_addf(&sb, "[%.*s]\n", store.baselen, key); | 553 | strbuf_addf(&sb, "[%.*s]\n", store.baselen, key); |
552 | } | 554 | } |
553 | 555 | ||
554 | success = write_in_full(fd, sb.buf, sb.len) == sb.len; | 556 | success = (write_in_full(fd, sb.buf, sb.len) == (ssize_t)sb.len); |
555 | strbuf_release(&sb); | 557 | strbuf_release(&sb); |
556 | 558 | ||
557 | return success; | 559 | return success; |
@@ -599,7 +601,7 @@ static int store_write_pair(int fd, const char* key, const char* value) | |||
599 | } | 601 | } |
600 | strbuf_addf(&sb, "%s\n", quote); | 602 | strbuf_addf(&sb, "%s\n", quote); |
601 | 603 | ||
602 | success = write_in_full(fd, sb.buf, sb.len) == sb.len; | 604 | success = (write_in_full(fd, sb.buf, sb.len) == (ssize_t)sb.len); |
603 | strbuf_release(&sb); | 605 | strbuf_release(&sb); |
604 | 606 | ||
605 | return success; | 607 | return success; |
@@ -741,7 +743,7 @@ int perf_config_set_multivar(const char* key, const char* value, | |||
741 | } else { | 743 | } else { |
742 | struct stat st; | 744 | struct stat st; |
743 | char* contents; | 745 | char* contents; |
744 | size_t contents_sz, copy_begin, copy_end; | 746 | ssize_t contents_sz, copy_begin, copy_end; |
745 | int i, new_line = 0; | 747 | int i, new_line = 0; |
746 | 748 | ||
747 | if (value_regex == NULL) | 749 | if (value_regex == NULL) |
diff --git a/tools/perf/util/exec_cmd.c b/tools/perf/util/exec_cmd.c index d39292263153..34a352867382 100644 --- a/tools/perf/util/exec_cmd.c +++ b/tools/perf/util/exec_cmd.c | |||
@@ -1,6 +1,9 @@ | |||
1 | #include "cache.h" | 1 | #include "cache.h" |
2 | #include "exec_cmd.h" | 2 | #include "exec_cmd.h" |
3 | #include "quote.h" | 3 | #include "quote.h" |
4 | |||
5 | #include <string.h> | ||
6 | |||
4 | #define MAX_ARGS 32 | 7 | #define MAX_ARGS 32 |
5 | 8 | ||
6 | extern char **environ; | 9 | extern char **environ; |
@@ -51,7 +54,7 @@ const char *perf_extract_argv0_path(const char *argv0) | |||
51 | slash--; | 54 | slash--; |
52 | 55 | ||
53 | if (slash >= argv0) { | 56 | if (slash >= argv0) { |
54 | argv0_path = strndup(argv0, slash - argv0); | 57 | argv0_path = xstrndup(argv0, slash - argv0); |
55 | return slash + 1; | 58 | return slash + 1; |
56 | } | 59 | } |
57 | 60 | ||
diff --git a/tools/perf/util/help.c b/tools/perf/util/help.c index 17a00e0df2c4..fbb00978b2e2 100644 --- a/tools/perf/util/help.c +++ b/tools/perf/util/help.c | |||
@@ -26,7 +26,7 @@ static int term_columns(void) | |||
26 | return 80; | 26 | return 80; |
27 | } | 27 | } |
28 | 28 | ||
29 | void add_cmdname(struct cmdnames *cmds, const char *name, int len) | 29 | void add_cmdname(struct cmdnames *cmds, const char *name, size_t len) |
30 | { | 30 | { |
31 | struct cmdname *ent = malloc(sizeof(*ent) + len + 1); | 31 | struct cmdname *ent = malloc(sizeof(*ent) + len + 1); |
32 | 32 | ||
@@ -40,7 +40,8 @@ void add_cmdname(struct cmdnames *cmds, const char *name, int len) | |||
40 | 40 | ||
41 | static void clean_cmdnames(struct cmdnames *cmds) | 41 | static void clean_cmdnames(struct cmdnames *cmds) |
42 | { | 42 | { |
43 | int i; | 43 | unsigned int i; |
44 | |||
44 | for (i = 0; i < cmds->cnt; ++i) | 45 | for (i = 0; i < cmds->cnt; ++i) |
45 | free(cmds->names[i]); | 46 | free(cmds->names[i]); |
46 | free(cmds->names); | 47 | free(cmds->names); |
@@ -57,7 +58,7 @@ static int cmdname_compare(const void *a_, const void *b_) | |||
57 | 58 | ||
58 | static void uniq(struct cmdnames *cmds) | 59 | static void uniq(struct cmdnames *cmds) |
59 | { | 60 | { |
60 | int i, j; | 61 | unsigned int i, j; |
61 | 62 | ||
62 | if (!cmds->cnt) | 63 | if (!cmds->cnt) |
63 | return; | 64 | return; |
@@ -71,7 +72,7 @@ static void uniq(struct cmdnames *cmds) | |||
71 | 72 | ||
72 | void exclude_cmds(struct cmdnames *cmds, struct cmdnames *excludes) | 73 | void exclude_cmds(struct cmdnames *cmds, struct cmdnames *excludes) |
73 | { | 74 | { |
74 | int ci, cj, ei; | 75 | size_t ci, cj, ei; |
75 | int cmp; | 76 | int cmp; |
76 | 77 | ||
77 | ci = cj = ei = 0; | 78 | ci = cj = ei = 0; |
@@ -106,8 +107,9 @@ static void pretty_print_string_list(struct cmdnames *cmds, int longest) | |||
106 | printf(" "); | 107 | printf(" "); |
107 | 108 | ||
108 | for (j = 0; j < cols; j++) { | 109 | for (j = 0; j < cols; j++) { |
109 | int n = j * rows + i; | 110 | unsigned int n = j * rows + i; |
110 | int size = space; | 111 | unsigned int size = space; |
112 | |||
111 | if (n >= cmds->cnt) | 113 | if (n >= cmds->cnt) |
112 | break; | 114 | break; |
113 | if (j == cols-1 || n + rows >= cmds->cnt) | 115 | if (j == cols-1 || n + rows >= cmds->cnt) |
@@ -208,7 +210,7 @@ void load_command_list(const char *prefix, | |||
208 | void list_commands(const char *title, struct cmdnames *main_cmds, | 210 | void list_commands(const char *title, struct cmdnames *main_cmds, |
209 | struct cmdnames *other_cmds) | 211 | struct cmdnames *other_cmds) |
210 | { | 212 | { |
211 | int i, longest = 0; | 213 | unsigned int i, longest = 0; |
212 | 214 | ||
213 | for (i = 0; i < main_cmds->cnt; i++) | 215 | for (i = 0; i < main_cmds->cnt; i++) |
214 | if (longest < main_cmds->names[i]->len) | 216 | if (longest < main_cmds->names[i]->len) |
@@ -239,7 +241,8 @@ void list_commands(const char *title, struct cmdnames *main_cmds, | |||
239 | 241 | ||
240 | int is_in_cmdlist(struct cmdnames *c, const char *s) | 242 | int is_in_cmdlist(struct cmdnames *c, const char *s) |
241 | { | 243 | { |
242 | int i; | 244 | unsigned int i; |
245 | |||
243 | for (i = 0; i < c->cnt; i++) | 246 | for (i = 0; i < c->cnt; i++) |
244 | if (!strcmp(s, c->names[i]->name)) | 247 | if (!strcmp(s, c->names[i]->name)) |
245 | return 1; | 248 | return 1; |
@@ -271,7 +274,8 @@ static int levenshtein_compare(const void *p1, const void *p2) | |||
271 | 274 | ||
272 | static void add_cmd_list(struct cmdnames *cmds, struct cmdnames *old) | 275 | static void add_cmd_list(struct cmdnames *cmds, struct cmdnames *old) |
273 | { | 276 | { |
274 | int i; | 277 | unsigned int i; |
278 | |||
275 | ALLOC_GROW(cmds->names, cmds->cnt + old->cnt, cmds->alloc); | 279 | ALLOC_GROW(cmds->names, cmds->cnt + old->cnt, cmds->alloc); |
276 | 280 | ||
277 | for (i = 0; i < old->cnt; i++) | 281 | for (i = 0; i < old->cnt; i++) |
@@ -283,7 +287,7 @@ static void add_cmd_list(struct cmdnames *cmds, struct cmdnames *old) | |||
283 | 287 | ||
284 | const char *help_unknown_cmd(const char *cmd) | 288 | const char *help_unknown_cmd(const char *cmd) |
285 | { | 289 | { |
286 | int i, n = 0, best_similarity = 0; | 290 | unsigned int i, n = 0, best_similarity = 0; |
287 | struct cmdnames main_cmds, other_cmds; | 291 | struct cmdnames main_cmds, other_cmds; |
288 | 292 | ||
289 | memset(&main_cmds, 0, sizeof(main_cmds)); | 293 | memset(&main_cmds, 0, sizeof(main_cmds)); |
@@ -345,7 +349,7 @@ const char *help_unknown_cmd(const char *cmd) | |||
345 | exit(1); | 349 | exit(1); |
346 | } | 350 | } |
347 | 351 | ||
348 | int cmd_version(int argc, const char **argv, const char *prefix) | 352 | int cmd_version(int argc __used, const char **argv __used, const char *prefix __used) |
349 | { | 353 | { |
350 | printf("perf version %s\n", perf_version_string); | 354 | printf("perf version %s\n", perf_version_string); |
351 | return 0; | 355 | return 0; |
diff --git a/tools/perf/util/help.h b/tools/perf/util/help.h index 56bc15406ffc..7128783637b4 100644 --- a/tools/perf/util/help.h +++ b/tools/perf/util/help.h | |||
@@ -2,8 +2,8 @@ | |||
2 | #define HELP_H | 2 | #define HELP_H |
3 | 3 | ||
4 | struct cmdnames { | 4 | struct cmdnames { |
5 | int alloc; | 5 | size_t alloc; |
6 | int cnt; | 6 | size_t cnt; |
7 | struct cmdname { | 7 | struct cmdname { |
8 | size_t len; /* also used for similarity index in help.c */ | 8 | size_t len; /* also used for similarity index in help.c */ |
9 | char name[FLEX_ARRAY]; | 9 | char name[FLEX_ARRAY]; |
@@ -19,7 +19,7 @@ static inline void mput_char(char c, unsigned int num) | |||
19 | void load_command_list(const char *prefix, | 19 | void load_command_list(const char *prefix, |
20 | struct cmdnames *main_cmds, | 20 | struct cmdnames *main_cmds, |
21 | struct cmdnames *other_cmds); | 21 | struct cmdnames *other_cmds); |
22 | void add_cmdname(struct cmdnames *cmds, const char *name, int len); | 22 | void add_cmdname(struct cmdnames *cmds, const char *name, size_t len); |
23 | /* Here we require that excludes is a sorted list. */ | 23 | /* Here we require that excludes is a sorted list. */ |
24 | void exclude_cmds(struct cmdnames *cmds, struct cmdnames *excludes); | 24 | void exclude_cmds(struct cmdnames *cmds, struct cmdnames *excludes); |
25 | int is_in_cmdlist(struct cmdnames *c, const char *s); | 25 | int is_in_cmdlist(struct cmdnames *c, const char *s); |
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index e6b83a3311a5..aed70901df24 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c | |||
@@ -385,7 +385,7 @@ static int parse_event_symbols(const char **str, struct perf_counter_attr *attr) | |||
385 | return 1; | 385 | return 1; |
386 | } | 386 | } |
387 | 387 | ||
388 | int parse_events(const struct option *opt, const char *str, int unset) | 388 | int parse_events(const struct option *opt __used, const char *str, int unset __used) |
389 | { | 389 | { |
390 | struct perf_counter_attr attr; | 390 | struct perf_counter_attr attr; |
391 | 391 | ||
diff --git a/tools/perf/util/parse-options.c b/tools/perf/util/parse-options.c index b3affb1658d2..9a897b7cce79 100644 --- a/tools/perf/util/parse-options.c +++ b/tools/perf/util/parse-options.c | |||
@@ -485,7 +485,7 @@ int parse_options_usage(const char * const *usagestr, | |||
485 | } | 485 | } |
486 | 486 | ||
487 | 487 | ||
488 | int parse_opt_verbosity_cb(const struct option *opt, const char *arg, | 488 | int parse_opt_verbosity_cb(const struct option *opt, const char *arg __used, |
489 | int unset) | 489 | int unset) |
490 | { | 490 | { |
491 | int *target = opt->value; | 491 | int *target = opt->value; |
diff --git a/tools/perf/util/parse-options.h b/tools/perf/util/parse-options.h index a1039a6ce0eb..15c8aba9c62e 100644 --- a/tools/perf/util/parse-options.h +++ b/tools/perf/util/parse-options.h | |||
@@ -90,21 +90,20 @@ struct option { | |||
90 | intptr_t defval; | 90 | intptr_t defval; |
91 | }; | 91 | }; |
92 | 92 | ||
93 | #define OPT_END() { OPTION_END } | 93 | #define OPT_END() { .type = OPTION_END } |
94 | #define OPT_ARGUMENT(l, h) { OPTION_ARGUMENT, 0, (l), NULL, NULL, (h) } | 94 | #define OPT_ARGUMENT(l, h) { .type = OPTION_ARGUMENT, .long_name = (l), .help = (h) } |
95 | #define OPT_GROUP(h) { OPTION_GROUP, 0, NULL, NULL, NULL, (h) } | 95 | #define OPT_GROUP(h) { .type = OPTION_GROUP, .help = (h) } |
96 | #define OPT_BIT(s, l, v, h, b) { OPTION_BIT, (s), (l), (v), NULL, (h), 0, NULL, (b) } | 96 | #define OPT_BIT(s, l, v, h, b) { .type = OPTION_BIT, .short_name = (s), .long_name = (l), .value = (v), .help = (h), .defval = (b) } |
97 | #define OPT_BOOLEAN(s, l, v, h) { OPTION_BOOLEAN, (s), (l), (v), NULL, (h) } | 97 | #define OPT_BOOLEAN(s, l, v, h) { .type = OPTION_BOOLEAN, .short_name = (s), .long_name = (l), .value = (v), .help = (h) } |
98 | #define OPT_SET_INT(s, l, v, h, i) { OPTION_SET_INT, (s), (l), (v), NULL, (h), 0, NULL, (i) } | 98 | #define OPT_SET_INT(s, l, v, h, i) { .type = OPTION_SET_INT, .short_name = (s), .long_name = (l), .value = (v), .help = (h), .defval = (i) } |
99 | #define OPT_SET_PTR(s, l, v, h, p) { OPTION_SET_PTR, (s), (l), (v), NULL, (h), 0, NULL, (p) } | 99 | #define OPT_SET_PTR(s, l, v, h, p) { .type = OPTION_SET_PTR, .short_name = (s), .long_name = (l), .value = (v), .help = (h), .defval = (p) } |
100 | #define OPT_INTEGER(s, l, v, h) { OPTION_INTEGER, (s), (l), (v), NULL, (h) } | 100 | #define OPT_INTEGER(s, l, v, h) { .type = OPTION_INTEGER, .short_name = (s), .long_name = (l), .value = (v), .help = (h) } |
101 | #define OPT_LONG(s, l, v, h) { OPTION_LONG, (s), (l), (v), NULL, (h) } | 101 | #define OPT_LONG(s, l, v, h) { .type = OPTION_LONG, .short_name = (s), .long_name = (l), .value = (v), .help = (h) } |
102 | #define OPT_STRING(s, l, v, a, h) { OPTION_STRING, (s), (l), (v), (a), (h) } | 102 | #define OPT_STRING(s, l, v, a, h) { .type = OPTION_STRING, .short_name = (s), .long_name = (l), .value = (v), (a), .help = (h) } |
103 | #define OPT_DATE(s, l, v, h) \ | 103 | #define OPT_DATE(s, l, v, h) \ |
104 | { OPTION_CALLBACK, (s), (l), (v), "time",(h), 0, \ | 104 | { .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value = (v), .argh = "time", .help = (h), .callback = parse_opt_approxidate_cb } |
105 | parse_opt_approxidate_cb } | ||
106 | #define OPT_CALLBACK(s, l, v, a, h, f) \ | 105 | #define OPT_CALLBACK(s, l, v, a, h, f) \ |
107 | { OPTION_CALLBACK, (s), (l), (v), (a), (h), 0, (f) } | 106 | { .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value = (v), (a), .help = (h), .callback = (f) } |
108 | 107 | ||
109 | /* parse_options() will filter out the processed options and leave the | 108 | /* parse_options() will filter out the processed options and leave the |
110 | * non-option argments in argv[]. | 109 | * non-option argments in argv[]. |
diff --git a/tools/perf/util/quote.c b/tools/perf/util/quote.c index f18c5212bc92..c6e5dc0dc82f 100644 --- a/tools/perf/util/quote.c +++ b/tools/perf/util/quote.c | |||
@@ -162,12 +162,16 @@ static inline int sq_must_quote(char c) | |||
162 | return sq_lookup[(unsigned char)c] + quote_path_fully > 0; | 162 | return sq_lookup[(unsigned char)c] + quote_path_fully > 0; |
163 | } | 163 | } |
164 | 164 | ||
165 | /* returns the longest prefix not needing a quote up to maxlen if positive. | 165 | /* |
166 | This stops at the first \0 because it's marked as a character needing an | 166 | * Returns the longest prefix not needing a quote up to maxlen if |
167 | escape */ | 167 | * positive. |
168 | static size_t next_quote_pos(const char *s, ssize_t maxlen) | 168 | * This stops at the first \0 because it's marked as a character |
169 | * needing an escape. | ||
170 | */ | ||
171 | static ssize_t next_quote_pos(const char *s, ssize_t maxlen) | ||
169 | { | 172 | { |
170 | size_t len; | 173 | ssize_t len; |
174 | |||
171 | if (maxlen < 0) { | 175 | if (maxlen < 0) { |
172 | for (len = 0; !sq_must_quote(s[len]); len++); | 176 | for (len = 0; !sq_must_quote(s[len]); len++); |
173 | } else { | 177 | } else { |
@@ -192,22 +196,22 @@ static size_t next_quote_pos(const char *s, ssize_t maxlen) | |||
192 | static size_t quote_c_style_counted(const char *name, ssize_t maxlen, | 196 | static size_t quote_c_style_counted(const char *name, ssize_t maxlen, |
193 | struct strbuf *sb, FILE *fp, int no_dq) | 197 | struct strbuf *sb, FILE *fp, int no_dq) |
194 | { | 198 | { |
195 | #undef EMIT | 199 | #define EMIT(c) \ |
196 | #define EMIT(c) \ | 200 | do { \ |
197 | do { \ | 201 | if (sb) strbuf_addch(sb, (c)); \ |
198 | if (sb) strbuf_addch(sb, (c)); \ | 202 | if (fp) fputc((c), fp); \ |
199 | if (fp) fputc((c), fp); \ | 203 | count++; \ |
200 | count++; \ | ||
201 | } while (0) | 204 | } while (0) |
202 | #define EMITBUF(s, l) \ | 205 | |
203 | do { \ | 206 | #define EMITBUF(s, l) \ |
204 | int __ret; \ | 207 | do { \ |
205 | if (sb) strbuf_add(sb, (s), (l)); \ | 208 | int __ret; \ |
206 | if (fp) __ret = fwrite((s), (l), 1, fp); \ | 209 | if (sb) strbuf_add(sb, (s), (l)); \ |
207 | count += (l); \ | 210 | if (fp) __ret = fwrite((s), (l), 1, fp); \ |
211 | count += (l); \ | ||
208 | } while (0) | 212 | } while (0) |
209 | 213 | ||
210 | size_t len, count = 0; | 214 | ssize_t len, count = 0; |
211 | const char *p = name; | 215 | const char *p = name; |
212 | 216 | ||
213 | for (;;) { | 217 | for (;;) { |
@@ -273,8 +277,8 @@ void write_name_quoted(const char *name, FILE *fp, int terminator) | |||
273 | fputc(terminator, fp); | 277 | fputc(terminator, fp); |
274 | } | 278 | } |
275 | 279 | ||
276 | extern void write_name_quotedpfx(const char *pfx, size_t pfxlen, | 280 | void write_name_quotedpfx(const char *pfx, ssize_t pfxlen, |
277 | const char *name, FILE *fp, int terminator) | 281 | const char *name, FILE *fp, int terminator) |
278 | { | 282 | { |
279 | int needquote = 0; | 283 | int needquote = 0; |
280 | 284 | ||
@@ -306,7 +310,7 @@ char *quote_path_relative(const char *in, int len, | |||
306 | len = strlen(in); | 310 | len = strlen(in); |
307 | 311 | ||
308 | /* "../" prefix itself does not need quoting, but "in" might. */ | 312 | /* "../" prefix itself does not need quoting, but "in" might. */ |
309 | needquote = next_quote_pos(in, len) < len; | 313 | needquote = (next_quote_pos(in, len) < len); |
310 | strbuf_setlen(out, 0); | 314 | strbuf_setlen(out, 0); |
311 | strbuf_grow(out, len); | 315 | strbuf_grow(out, len); |
312 | 316 | ||
diff --git a/tools/perf/util/quote.h b/tools/perf/util/quote.h index 5dfad89816db..a5454a1d1c13 100644 --- a/tools/perf/util/quote.h +++ b/tools/perf/util/quote.h | |||
@@ -53,7 +53,7 @@ extern size_t quote_c_style(const char *name, struct strbuf *, FILE *, int no_dq | |||
53 | extern void quote_two_c_style(struct strbuf *, const char *, const char *, int); | 53 | extern void quote_two_c_style(struct strbuf *, const char *, const char *, int); |
54 | 54 | ||
55 | extern void write_name_quoted(const char *name, FILE *, int terminator); | 55 | extern void write_name_quoted(const char *name, FILE *, int terminator); |
56 | extern void write_name_quotedpfx(const char *pfx, size_t pfxlen, | 56 | extern void write_name_quotedpfx(const char *pfx, ssize_t pfxlen, |
57 | const char *name, FILE *, int terminator); | 57 | const char *name, FILE *, int terminator); |
58 | 58 | ||
59 | /* quote path as relative to the given prefix */ | 59 | /* quote path as relative to the given prefix */ |
diff --git a/tools/perf/util/strbuf.c b/tools/perf/util/strbuf.c index 464e7ca898cf..5249d5a1b0c2 100644 --- a/tools/perf/util/strbuf.c +++ b/tools/perf/util/strbuf.c | |||
@@ -16,7 +16,7 @@ int prefixcmp(const char *str, const char *prefix) | |||
16 | */ | 16 | */ |
17 | char strbuf_slopbuf[1]; | 17 | char strbuf_slopbuf[1]; |
18 | 18 | ||
19 | void strbuf_init(struct strbuf *sb, size_t hint) | 19 | void strbuf_init(struct strbuf *sb, ssize_t hint) |
20 | { | 20 | { |
21 | sb->alloc = sb->len = 0; | 21 | sb->alloc = sb->len = 0; |
22 | sb->buf = strbuf_slopbuf; | 22 | sb->buf = strbuf_slopbuf; |
@@ -92,7 +92,8 @@ void strbuf_ltrim(struct strbuf *sb) | |||
92 | 92 | ||
93 | void strbuf_tolower(struct strbuf *sb) | 93 | void strbuf_tolower(struct strbuf *sb) |
94 | { | 94 | { |
95 | int i; | 95 | unsigned int i; |
96 | |||
96 | for (i = 0; i < sb->len; i++) | 97 | for (i = 0; i < sb->len; i++) |
97 | sb->buf[i] = tolower(sb->buf[i]); | 98 | sb->buf[i] = tolower(sb->buf[i]); |
98 | } | 99 | } |
@@ -264,7 +265,7 @@ size_t strbuf_fread(struct strbuf *sb, size_t size, FILE *f) | |||
264 | return res; | 265 | return res; |
265 | } | 266 | } |
266 | 267 | ||
267 | ssize_t strbuf_read(struct strbuf *sb, int fd, size_t hint) | 268 | ssize_t strbuf_read(struct strbuf *sb, int fd, ssize_t hint) |
268 | { | 269 | { |
269 | size_t oldlen = sb->len; | 270 | size_t oldlen = sb->len; |
270 | size_t oldalloc = sb->alloc; | 271 | size_t oldalloc = sb->alloc; |
@@ -293,7 +294,7 @@ ssize_t strbuf_read(struct strbuf *sb, int fd, size_t hint) | |||
293 | 294 | ||
294 | #define STRBUF_MAXLINK (2*PATH_MAX) | 295 | #define STRBUF_MAXLINK (2*PATH_MAX) |
295 | 296 | ||
296 | int strbuf_readlink(struct strbuf *sb, const char *path, size_t hint) | 297 | int strbuf_readlink(struct strbuf *sb, const char *path, ssize_t hint) |
297 | { | 298 | { |
298 | size_t oldalloc = sb->alloc; | 299 | size_t oldalloc = sb->alloc; |
299 | 300 | ||
@@ -301,7 +302,7 @@ int strbuf_readlink(struct strbuf *sb, const char *path, size_t hint) | |||
301 | hint = 32; | 302 | hint = 32; |
302 | 303 | ||
303 | while (hint < STRBUF_MAXLINK) { | 304 | while (hint < STRBUF_MAXLINK) { |
304 | int len; | 305 | ssize_t len; |
305 | 306 | ||
306 | strbuf_grow(sb, hint); | 307 | strbuf_grow(sb, hint); |
307 | len = readlink(path, sb->buf, hint); | 308 | len = readlink(path, sb->buf, hint); |
@@ -343,7 +344,7 @@ int strbuf_getline(struct strbuf *sb, FILE *fp, int term) | |||
343 | return 0; | 344 | return 0; |
344 | } | 345 | } |
345 | 346 | ||
346 | int strbuf_read_file(struct strbuf *sb, const char *path, size_t hint) | 347 | int strbuf_read_file(struct strbuf *sb, const char *path, ssize_t hint) |
347 | { | 348 | { |
348 | int fd, len; | 349 | int fd, len; |
349 | 350 | ||
diff --git a/tools/perf/util/strbuf.h b/tools/perf/util/strbuf.h index 9ee908a3ec5d..d2aa86c014c1 100644 --- a/tools/perf/util/strbuf.h +++ b/tools/perf/util/strbuf.h | |||
@@ -50,7 +50,7 @@ struct strbuf { | |||
50 | #define STRBUF_INIT { 0, 0, strbuf_slopbuf } | 50 | #define STRBUF_INIT { 0, 0, strbuf_slopbuf } |
51 | 51 | ||
52 | /*----- strbuf life cycle -----*/ | 52 | /*----- strbuf life cycle -----*/ |
53 | extern void strbuf_init(struct strbuf *, size_t); | 53 | extern void strbuf_init(struct strbuf *buf, ssize_t hint); |
54 | extern void strbuf_release(struct strbuf *); | 54 | extern void strbuf_release(struct strbuf *); |
55 | extern char *strbuf_detach(struct strbuf *, size_t *); | 55 | extern char *strbuf_detach(struct strbuf *, size_t *); |
56 | extern void strbuf_attach(struct strbuf *, void *, size_t, size_t); | 56 | extern void strbuf_attach(struct strbuf *, void *, size_t, size_t); |
@@ -61,7 +61,7 @@ static inline void strbuf_swap(struct strbuf *a, struct strbuf *b) { | |||
61 | } | 61 | } |
62 | 62 | ||
63 | /*----- strbuf size related -----*/ | 63 | /*----- strbuf size related -----*/ |
64 | static inline size_t strbuf_avail(const struct strbuf *sb) { | 64 | static inline ssize_t strbuf_avail(const struct strbuf *sb) { |
65 | return sb->alloc ? sb->alloc - sb->len - 1 : 0; | 65 | return sb->alloc ? sb->alloc - sb->len - 1 : 0; |
66 | } | 66 | } |
67 | 67 | ||
@@ -122,9 +122,9 @@ extern void strbuf_addf(struct strbuf *sb, const char *fmt, ...); | |||
122 | 122 | ||
123 | extern size_t strbuf_fread(struct strbuf *, size_t, FILE *); | 123 | extern size_t strbuf_fread(struct strbuf *, size_t, FILE *); |
124 | /* XXX: if read fails, any partial read is undone */ | 124 | /* XXX: if read fails, any partial read is undone */ |
125 | extern ssize_t strbuf_read(struct strbuf *, int fd, size_t hint); | 125 | extern ssize_t strbuf_read(struct strbuf *, int fd, ssize_t hint); |
126 | extern int strbuf_read_file(struct strbuf *sb, const char *path, size_t hint); | 126 | extern int strbuf_read_file(struct strbuf *sb, const char *path, ssize_t hint); |
127 | extern int strbuf_readlink(struct strbuf *sb, const char *path, size_t hint); | 127 | extern int strbuf_readlink(struct strbuf *sb, const char *path, ssize_t hint); |
128 | 128 | ||
129 | extern int strbuf_getline(struct strbuf *, FILE *, int); | 129 | extern int strbuf_getline(struct strbuf *, FILE *, int); |
130 | 130 | ||
diff --git a/tools/perf/util/wrapper.c b/tools/perf/util/wrapper.c index 6350d65f6d9e..4574ac28396f 100644 --- a/tools/perf/util/wrapper.c +++ b/tools/perf/util/wrapper.c | |||
@@ -7,7 +7,7 @@ | |||
7 | * There's no pack memory to release - but stay close to the Git | 7 | * There's no pack memory to release - but stay close to the Git |
8 | * version so wrap this away: | 8 | * version so wrap this away: |
9 | */ | 9 | */ |
10 | static inline void release_pack_memory(size_t size, int flag) | 10 | static inline void release_pack_memory(size_t size __used, int flag __used) |
11 | { | 11 | { |
12 | } | 12 | } |
13 | 13 | ||
@@ -59,7 +59,8 @@ void *xmemdupz(const void *data, size_t len) | |||
59 | char *xstrndup(const char *str, size_t len) | 59 | char *xstrndup(const char *str, size_t len) |
60 | { | 60 | { |
61 | char *p = memchr(str, '\0', len); | 61 | char *p = memchr(str, '\0', len); |
62 | return xmemdupz(str, p ? p - str : len); | 62 | |
63 | return xmemdupz(str, p ? (size_t)(p - str) : len); | ||
63 | } | 64 | } |
64 | 65 | ||
65 | void *xrealloc(void *ptr, size_t size) | 66 | void *xrealloc(void *ptr, size_t size) |