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/util/parse-events.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/util/parse-events.c')
-rw-r--r-- | tools/perf/util/parse-events.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 044178408783..1cda97b39118 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c | |||
@@ -14,10 +14,10 @@ int nr_counters; | |||
14 | struct perf_counter_attr attrs[MAX_COUNTERS]; | 14 | struct perf_counter_attr attrs[MAX_COUNTERS]; |
15 | 15 | ||
16 | struct event_symbol { | 16 | struct event_symbol { |
17 | u8 type; | 17 | u8 type; |
18 | u64 config; | 18 | u64 config; |
19 | char *symbol; | 19 | const char *symbol; |
20 | char *alias; | 20 | const char *alias; |
21 | }; | 21 | }; |
22 | 22 | ||
23 | char debugfs_path[MAXPATHLEN]; | 23 | char debugfs_path[MAXPATHLEN]; |
@@ -51,7 +51,7 @@ static struct event_symbol event_symbols[] = { | |||
51 | #define PERF_COUNTER_TYPE(config) __PERF_COUNTER_FIELD(config, TYPE) | 51 | #define PERF_COUNTER_TYPE(config) __PERF_COUNTER_FIELD(config, TYPE) |
52 | #define PERF_COUNTER_ID(config) __PERF_COUNTER_FIELD(config, EVENT) | 52 | #define PERF_COUNTER_ID(config) __PERF_COUNTER_FIELD(config, EVENT) |
53 | 53 | ||
54 | static char *hw_event_names[] = { | 54 | static const char *hw_event_names[] = { |
55 | "cycles", | 55 | "cycles", |
56 | "instructions", | 56 | "instructions", |
57 | "cache-references", | 57 | "cache-references", |
@@ -61,7 +61,7 @@ static char *hw_event_names[] = { | |||
61 | "bus-cycles", | 61 | "bus-cycles", |
62 | }; | 62 | }; |
63 | 63 | ||
64 | static char *sw_event_names[] = { | 64 | static const char *sw_event_names[] = { |
65 | "cpu-clock-msecs", | 65 | "cpu-clock-msecs", |
66 | "task-clock-msecs", | 66 | "task-clock-msecs", |
67 | "page-faults", | 67 | "page-faults", |
@@ -73,7 +73,7 @@ static char *sw_event_names[] = { | |||
73 | 73 | ||
74 | #define MAX_ALIASES 8 | 74 | #define MAX_ALIASES 8 |
75 | 75 | ||
76 | static char *hw_cache[][MAX_ALIASES] = { | 76 | static const char *hw_cache[][MAX_ALIASES] = { |
77 | { "L1-dcache", "l1-d", "l1d", "L1-data", }, | 77 | { "L1-dcache", "l1-d", "l1d", "L1-data", }, |
78 | { "L1-icache", "l1-i", "l1i", "L1-instruction", }, | 78 | { "L1-icache", "l1-i", "l1i", "L1-instruction", }, |
79 | { "LLC", "L2" }, | 79 | { "LLC", "L2" }, |
@@ -82,13 +82,13 @@ static char *hw_cache[][MAX_ALIASES] = { | |||
82 | { "branch", "branches", "bpu", "btb", "bpc", }, | 82 | { "branch", "branches", "bpu", "btb", "bpc", }, |
83 | }; | 83 | }; |
84 | 84 | ||
85 | static char *hw_cache_op[][MAX_ALIASES] = { | 85 | static const char *hw_cache_op[][MAX_ALIASES] = { |
86 | { "load", "loads", "read", }, | 86 | { "load", "loads", "read", }, |
87 | { "store", "stores", "write", }, | 87 | { "store", "stores", "write", }, |
88 | { "prefetch", "prefetches", "speculative-read", "speculative-load", }, | 88 | { "prefetch", "prefetches", "speculative-read", "speculative-load", }, |
89 | }; | 89 | }; |
90 | 90 | ||
91 | static char *hw_cache_result[][MAX_ALIASES] = { | 91 | static const char *hw_cache_result[][MAX_ALIASES] = { |
92 | { "refs", "Reference", "ops", "access", }, | 92 | { "refs", "Reference", "ops", "access", }, |
93 | { "misses", "miss", }, | 93 | { "misses", "miss", }, |
94 | }; | 94 | }; |
@@ -158,7 +158,7 @@ int valid_debugfs_mount(const char *debugfs) | |||
158 | return 0; | 158 | return 0; |
159 | } | 159 | } |
160 | 160 | ||
161 | static char *tracepoint_id_to_name(u64 config) | 161 | static const char *tracepoint_id_to_name(u64 config) |
162 | { | 162 | { |
163 | static char tracepoint_name[2 * MAX_EVENT_LENGTH]; | 163 | static char tracepoint_name[2 * MAX_EVENT_LENGTH]; |
164 | DIR *sys_dir, *evt_dir; | 164 | DIR *sys_dir, *evt_dir; |
@@ -235,7 +235,7 @@ static char *event_cache_name(u8 cache_type, u8 cache_op, u8 cache_result) | |||
235 | return name; | 235 | return name; |
236 | } | 236 | } |
237 | 237 | ||
238 | char *event_name(int counter) | 238 | const char *event_name(int counter) |
239 | { | 239 | { |
240 | u64 config = attrs[counter].config; | 240 | u64 config = attrs[counter].config; |
241 | int type = attrs[counter].type; | 241 | int type = attrs[counter].type; |
@@ -243,7 +243,7 @@ char *event_name(int counter) | |||
243 | return __event_name(type, config); | 243 | return __event_name(type, config); |
244 | } | 244 | } |
245 | 245 | ||
246 | char *__event_name(int type, u64 config) | 246 | const char *__event_name(int type, u64 config) |
247 | { | 247 | { |
248 | static char buf[32]; | 248 | static char buf[32]; |
249 | 249 | ||
@@ -294,7 +294,7 @@ char *__event_name(int type, u64 config) | |||
294 | return "unknown"; | 294 | return "unknown"; |
295 | } | 295 | } |
296 | 296 | ||
297 | static int parse_aliases(const char **str, char *names[][MAX_ALIASES], int size) | 297 | static int parse_aliases(const char **str, const char *names[][MAX_ALIASES], int size) |
298 | { | 298 | { |
299 | int i, j; | 299 | int i, j; |
300 | int n, longest = -1; | 300 | int n, longest = -1; |