Skip to content

Commit

Permalink
perf top: Use a macro instead of a constant variable
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
acmel authored and Ingo Molnar committed Feb 25, 2010
1 parent 37fe5fc commit c7ad21a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tools/perf/builtin-top.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,19 +287,20 @@ static void record_precise_ip(struct sym_entry *syme, int counter, u64 ip)
pthread_mutex_unlock(&syme->src->lock);
}

#define PATTERN_LEN (BITS_PER_LONG / 4 + 2)

static void lookup_sym_source(struct sym_entry *syme)
{
struct symbol *symbol = sym_entry__symbol(syme);
struct source_line *line;
const size_t pattern_len = BITS_PER_LONG / 4 + 2;
char pattern[pattern_len + 1];
char pattern[PATTERN_LEN + 1];

sprintf(pattern, "%0*Lx <", BITS_PER_LONG / 4,
map__rip_2objdump(syme->map, symbol->start));

pthread_mutex_lock(&syme->src->lock);
for (line = syme->src->lines; line; line = line->next) {
if (memcmp(line->line, pattern, pattern_len) == 0) {
if (memcmp(line->line, pattern, PATTERN_LEN) == 0) {
syme->src->source = line;
break;
}
Expand Down

0 comments on commit c7ad21a

Please sign in to comment.