diff options
author | Ingo Molnar <mingo@elte.hu> | 2009-08-15 06:26:57 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-08-16 04:47:47 -0400 |
commit | 83a0944fa919fb2ebcfc1f8933d86e437b597ca6 (patch) | |
tree | 814906744656554a1bc07cdad6b84b3581565358 /tools/perf/builtin-top.c | |
parent | 6baa0a5ae0954fb2486c480a20556a9f1aee0965 (diff) |
perf: Enable more compiler warnings
Related to a shadowed variable bug fix Valdis Kletnieks noticed
that perf does not get built with -Wshadow, which could have
helped us avoid the bug.
So enable -Wshadow and also enable the following warnings on
perf builds, in addition to the already enabled -Wall -Wextra
-std=gnu99 warnings:
-Wcast-align
-Wformat=2
-Wshadow
-Winit-self
-Wpacked
-Wredundant-decls
-Wstack-protector
-Wstrict-aliasing=3
-Wswitch-default
-Wswitch-enum
-Wno-system-headers
-Wundef
-Wvolatile-register-var
-Wwrite-strings
-Wbad-function-cast
-Wmissing-declarations
-Wmissing-prototypes
-Wnested-externs
-Wold-style-definition
-Wstrict-prototypes
-Wdeclaration-after-statement
And change/fix the perf code to build cleanly under GCC 4.3.2.
The list of warnings enablement is rather arbitrary: it's based
on my (quick) reading of the GCC manpages and trying them on
perf.
I categorized the warnings based on individually enabling them
and looking whether they trigger something in the perf build.
If i liked those warnings (i.e. if they trigger for something
that arguably could be improved) i enabled the warning.
If the warnings seemed to come from language laywers spamming
the build with tons of nuisance warnings i generally kept them
off. Most of the sign conversion related warnings were in
this category. (A second patch enabling some of the sign
warnings might be welcome - sign bugs can be nasty.)
I also kept warnings that seem to make sense from their manpage
description and which produced no actual warnings on our code
base. These warnings might still be turned off if they end up
being a nuisance.
I also left out a few warnings that are not supported in older
compilers.
[ Note that these changes might break the build on older
compilers i did not test, or on non-x86 architectures that
produce different warnings, so more testing would be welcome. ]
Reported-by: Valdis.Kletnieks@vt.edu
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-top.c')
-rw-r--r-- | tools/perf/builtin-top.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 9a6dbbff9a9f..06f763e4b35b 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
@@ -120,7 +120,8 @@ static void parse_source(struct sym_entry *syme) | |||
120 | struct module *module; | 120 | struct module *module; |
121 | struct section *section = NULL; | 121 | struct section *section = NULL; |
122 | FILE *file; | 122 | FILE *file; |
123 | char command[PATH_MAX*2], *path = vmlinux; | 123 | char command[PATH_MAX*2]; |
124 | const char *path = vmlinux_name; | ||
124 | u64 start, end, len; | 125 | u64 start, end, len; |
125 | 126 | ||
126 | if (!syme) | 127 | if (!syme) |
@@ -487,10 +488,12 @@ static void print_sym_table(void) | |||
487 | ); | 488 | ); |
488 | 489 | ||
489 | for (nd = rb_first(&tmp); nd; nd = rb_next(nd)) { | 490 | for (nd = rb_first(&tmp); nd; nd = rb_next(nd)) { |
490 | struct sym_entry *syme = rb_entry(nd, struct sym_entry, rb_node); | 491 | struct symbol *sym; |
491 | struct symbol *sym = (struct symbol *)(syme + 1); | ||
492 | double pcnt; | 492 | double pcnt; |
493 | 493 | ||
494 | syme = rb_entry(nd, struct sym_entry, rb_node); | ||
495 | sym = (struct symbol *)(syme + 1); | ||
496 | |||
494 | if (++printed > print_entries || (int)syme->snap_count < count_filter) | 497 | if (++printed > print_entries || (int)syme->snap_count < count_filter) |
495 | continue; | 498 | continue; |
496 | 499 | ||
@@ -609,7 +612,7 @@ static void print_mapped_keys(void) | |||
609 | 612 | ||
610 | fprintf(stdout, "\t[f] profile display filter (count). \t(%d)\n", count_filter); | 613 | fprintf(stdout, "\t[f] profile display filter (count). \t(%d)\n", count_filter); |
611 | 614 | ||
612 | if (vmlinux) { | 615 | if (vmlinux_name) { |
613 | fprintf(stdout, "\t[F] annotate display filter (percent). \t(%d%%)\n", sym_pcnt_filter); | 616 | fprintf(stdout, "\t[F] annotate display filter (percent). \t(%d%%)\n", sym_pcnt_filter); |
614 | fprintf(stdout, "\t[s] annotate symbol. \t(%s)\n", name?: "NULL"); | 617 | fprintf(stdout, "\t[s] annotate symbol. \t(%s)\n", name?: "NULL"); |
615 | fprintf(stdout, "\t[S] stop annotation.\n"); | 618 | fprintf(stdout, "\t[S] stop annotation.\n"); |
@@ -638,7 +641,9 @@ static int key_mapped(int c) | |||
638 | case 'F': | 641 | case 'F': |
639 | case 's': | 642 | case 's': |
640 | case 'S': | 643 | case 'S': |
641 | return vmlinux ? 1 : 0; | 644 | return vmlinux_name ? 1 : 0; |
645 | default: | ||
646 | break; | ||
642 | } | 647 | } |
643 | 648 | ||
644 | return 0; | 649 | return 0; |
@@ -724,6 +729,8 @@ static void handle_keypress(int c) | |||
724 | case 'z': | 729 | case 'z': |
725 | zero = ~zero; | 730 | zero = ~zero; |
726 | break; | 731 | break; |
732 | default: | ||
733 | break; | ||
727 | } | 734 | } |
728 | } | 735 | } |
729 | 736 | ||
@@ -812,13 +819,13 @@ static int parse_symbols(void) | |||
812 | { | 819 | { |
813 | struct rb_node *node; | 820 | struct rb_node *node; |
814 | struct symbol *sym; | 821 | struct symbol *sym; |
815 | int modules = vmlinux ? 1 : 0; | 822 | int use_modules = vmlinux_name ? 1 : 0; |
816 | 823 | ||
817 | kernel_dso = dso__new("[kernel]", sizeof(struct sym_entry)); | 824 | kernel_dso = dso__new("[kernel]", sizeof(struct sym_entry)); |
818 | if (kernel_dso == NULL) | 825 | if (kernel_dso == NULL) |
819 | return -1; | 826 | return -1; |
820 | 827 | ||
821 | if (dso__load_kernel(kernel_dso, vmlinux, symbol_filter, verbose, modules) <= 0) | 828 | if (dso__load_kernel(kernel_dso, vmlinux_name, symbol_filter, verbose, use_modules) <= 0) |
822 | goto out_delete_dso; | 829 | goto out_delete_dso; |
823 | 830 | ||
824 | node = rb_first(&kernel_dso->syms); | 831 | node = rb_first(&kernel_dso->syms); |
@@ -1114,7 +1121,7 @@ static const struct option options[] = { | |||
1114 | "system-wide collection from all CPUs"), | 1121 | "system-wide collection from all CPUs"), |
1115 | OPT_INTEGER('C', "CPU", &profile_cpu, | 1122 | OPT_INTEGER('C', "CPU", &profile_cpu, |
1116 | "CPU to profile on"), | 1123 | "CPU to profile on"), |
1117 | OPT_STRING('k', "vmlinux", &vmlinux, "file", "vmlinux pathname"), | 1124 | OPT_STRING('k', "vmlinux", &vmlinux_name, "file", "vmlinux pathname"), |
1118 | OPT_INTEGER('m', "mmap-pages", &mmap_pages, | 1125 | OPT_INTEGER('m', "mmap-pages", &mmap_pages, |
1119 | "number of mmap data pages"), | 1126 | "number of mmap data pages"), |
1120 | OPT_INTEGER('r', "realtime", &realtime_prio, | 1127 | OPT_INTEGER('r', "realtime", &realtime_prio, |