Skip to content

Commit

Permalink
perf top: Fix uninitialized 'counter' variable
Browse files Browse the repository at this point in the history
builtin-top.c has an uninitialized variable.
gcc(version 4.5.1) warns about it and it results in build failure:

 builtin-top.c: In function 'display_thread':
 builtin-top.c:518:9: error: 'counter' may be used uninitialized

This situation can indeed trigger, if the getline() call in
prompt_integer() fails.

Signed-off-by: Akihiro Nagai <akihiro.nagai.hw@hitachi.com>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
LKML-Reference: <20110323072939.11638.50173.stgit@localhost6.localdomain6>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Akihiro Nagai authored and Ingo Molnar committed Mar 23, 2011
1 parent e1eb029 commit ce2d17c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tools/perf/builtin-top.c
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,9 @@ static void handle_keypress(struct perf_session *session, int c)
break;
case 'E':
if (top.evlist->nr_entries > 1) {
int counter;
/* Select 0 as the default event: */
int counter = 0;

fprintf(stderr, "\nAvailable events:");

list_for_each_entry(top.sym_evsel, &top.evlist->entries, node)
Expand Down

0 comments on commit ce2d17c

Please sign in to comment.