diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2010-02-22 14:14:22 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2010-02-25 06:26:16 -0500 |
commit | c7ad21af2c8b7accb893a576b100296c61c5d610 (patch) | |
tree | 8f12dbcd9f6b2227e7d2c1e05cc9729c27433e60 | |
parent | 37fe5fcb7a5b5235c8b71bf5469ce4c7246e3fab (diff) |
perf top: Use a macro instead of a constant variable
To overcome a silly gcc warning:
cc1: warnings being treated as errors
builtin-top.c: In function ‘lookup_sym_source’:
builtin-top.c:291: warning: not protecting local variables:
variable length buffer make: *** [builtin-top.o] Error 1
make: *** Waiting for unfinished jobs....
That is emitted for this:
const size_t pattern_len = BITS_PER_LONG / 4 + 2;
char pattern[pattern_len + 1];
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
LKML-Reference: <1266866062-6287-1-git-send-email-acme@infradead.org>
[ -v2: macroify the naming style ]
Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r-- | tools/perf/builtin-top.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index c72ab50d65ca..c6706984b7b3 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
@@ -287,19 +287,20 @@ out_unlock: | |||
287 | pthread_mutex_unlock(&syme->src->lock); | 287 | pthread_mutex_unlock(&syme->src->lock); |
288 | } | 288 | } |
289 | 289 | ||
290 | #define PATTERN_LEN (BITS_PER_LONG / 4 + 2) | ||
291 | |||
290 | static void lookup_sym_source(struct sym_entry *syme) | 292 | static void lookup_sym_source(struct sym_entry *syme) |
291 | { | 293 | { |
292 | struct symbol *symbol = sym_entry__symbol(syme); | 294 | struct symbol *symbol = sym_entry__symbol(syme); |
293 | struct source_line *line; | 295 | struct source_line *line; |
294 | const size_t pattern_len = BITS_PER_LONG / 4 + 2; | 296 | char pattern[PATTERN_LEN + 1]; |
295 | char pattern[pattern_len + 1]; | ||
296 | 297 | ||
297 | sprintf(pattern, "%0*Lx <", BITS_PER_LONG / 4, | 298 | sprintf(pattern, "%0*Lx <", BITS_PER_LONG / 4, |
298 | map__rip_2objdump(syme->map, symbol->start)); | 299 | map__rip_2objdump(syme->map, symbol->start)); |
299 | 300 | ||
300 | pthread_mutex_lock(&syme->src->lock); | 301 | pthread_mutex_lock(&syme->src->lock); |
301 | for (line = syme->src->lines; line; line = line->next) { | 302 | for (line = syme->src->lines; line; line = line->next) { |
302 | if (memcmp(line->line, pattern, pattern_len) == 0) { | 303 | if (memcmp(line->line, pattern, PATTERN_LEN) == 0) { |
303 | syme->src->source = line; | 304 | syme->src->source = line; |
304 | break; | 305 | break; |
305 | } | 306 | } |