diff options
author | Ingo Molnar <mingo@elte.hu> | 2009-09-02 08:55:55 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-09-02 08:56:33 -0400 |
commit | 65014ab36196f6d86edc9ee23759d6930b9d89a8 (patch) | |
tree | 4e3a802e3eae688b53f946560fe583d16f4c0c58 /tools | |
parent | 61562445c80452ec417fb6a6895b991f6c1dd930 (diff) |
perf tools: Work around strict aliasing related warnings
Older versions of GCC are rather stupid about strict aliasing:
util/trace-event-parse.c: In function 'parse_cmdlines':
util/trace-event-parse.c:93: warning: dereferencing type-punned pointer will break strict-aliasing rules
util/trace-event-parse.c: In function 'parse_proc_kallsyms':
util/trace-event-parse.c:155: warning: dereferencing type-punned pointer will break strict-aliasing rules
util/trace-event-parse.c:157: warning: dereferencing type-punned pointer will break strict-aliasing rules
util/trace-event-parse.c:158: warning: dereferencing type-punned pointer will break strict-aliasing rules
util/trace-event-parse.c: In function 'parse_ftrace_printk':
util/trace-event-parse.c:294: warning: dereferencing type-punned pointer will break strict-aliasing rules
util/trace-event-parse.c:295: warning: dereferencing type-punned pointer will break strict-aliasing rules
make: *** [util/trace-event-parse.o] Error 1
Make it clear to GCC that we intend with those pointers, by passing
them through via an explicit (void *) cast.
We might want to add -fno-strict-aliasing as well, like the kernel
itself does.
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')
-rw-r--r-- | tools/perf/util/trace-event-info.c | 2 | ||||
-rw-r--r-- | tools/perf/util/trace-event-parse.c | 12 |
2 files changed, 7 insertions, 7 deletions
diff --git a/tools/perf/util/trace-event-info.c b/tools/perf/util/trace-event-info.c index 81615279b876..6c9302a7274c 100644 --- a/tools/perf/util/trace-event-info.c +++ b/tools/perf/util/trace-event-info.c | |||
@@ -188,7 +188,7 @@ int bigendian(void) | |||
188 | unsigned char str[] = { 0x1, 0x2, 0x3, 0x4, 0x0, 0x0, 0x0, 0x0}; | 188 | unsigned char str[] = { 0x1, 0x2, 0x3, 0x4, 0x0, 0x0, 0x0, 0x0}; |
189 | unsigned int *ptr; | 189 | unsigned int *ptr; |
190 | 190 | ||
191 | ptr = (unsigned int *)str; | 191 | ptr = (unsigned int *)(void *)str; |
192 | return *ptr == 0x01020304; | 192 | return *ptr == 0x01020304; |
193 | } | 193 | } |
194 | 194 | ||
diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c index 665dac20cd1e..37b10c2cd3c9 100644 --- a/tools/perf/util/trace-event-parse.c +++ b/tools/perf/util/trace-event-parse.c | |||
@@ -90,7 +90,7 @@ void parse_cmdlines(char *file, int size __unused) | |||
90 | while (line) { | 90 | while (line) { |
91 | item = malloc_or_die(sizeof(*item)); | 91 | item = malloc_or_die(sizeof(*item)); |
92 | sscanf(line, "%d %as", &item->pid, | 92 | sscanf(line, "%d %as", &item->pid, |
93 | (float *)&item->comm); /* workaround gcc warning */ | 93 | (float *)(void *)&item->comm); /* workaround gcc warning */ |
94 | item->next = list; | 94 | item->next = list; |
95 | list = item; | 95 | list = item; |
96 | line = strtok_r(NULL, "\n", &next); | 96 | line = strtok_r(NULL, "\n", &next); |
@@ -152,10 +152,10 @@ void parse_proc_kallsyms(char *file, unsigned int size __unused) | |||
152 | item = malloc_or_die(sizeof(*item)); | 152 | item = malloc_or_die(sizeof(*item)); |
153 | item->mod = NULL; | 153 | item->mod = NULL; |
154 | ret = sscanf(line, "%as %c %as\t[%as", | 154 | ret = sscanf(line, "%as %c %as\t[%as", |
155 | (float *)&addr_str, /* workaround gcc warning */ | 155 | (float *)(void *)&addr_str, /* workaround gcc warning */ |
156 | &ch, | 156 | &ch, |
157 | (float *)&item->func, | 157 | (float *)(void *)&item->func, |
158 | (float *)&item->mod); | 158 | (float *)(void *)&item->mod); |
159 | item->addr = strtoull(addr_str, NULL, 16); | 159 | item->addr = strtoull(addr_str, NULL, 16); |
160 | free(addr_str); | 160 | free(addr_str); |
161 | 161 | ||
@@ -291,8 +291,8 @@ void parse_ftrace_printk(char *file, unsigned int size __unused) | |||
291 | while (line) { | 291 | while (line) { |
292 | item = malloc_or_die(sizeof(*item)); | 292 | item = malloc_or_die(sizeof(*item)); |
293 | ret = sscanf(line, "%as : %as", | 293 | ret = sscanf(line, "%as : %as", |
294 | (float *)&addr_str, /* workaround gcc warning */ | 294 | (float *)(void *)&addr_str, /* workaround gcc warning */ |
295 | (float *)&item->printk); | 295 | (float *)(void *)&item->printk); |
296 | item->addr = strtoull(addr_str, NULL, 16); | 296 | item->addr = strtoull(addr_str, NULL, 16); |
297 | free(addr_str); | 297 | free(addr_str); |
298 | 298 | ||