public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH -tip ] [BUGFIX] perf-top: Fix uninitialized variable
@ 2011-03-23  7:29 Akihiro Nagai
  2011-03-23  9:43 ` [tip:perf/urgent] perf top: Fix uninitialized 'counter' variable tip-bot for Akihiro Nagai
  0 siblings, 1 reply; 2+ messages in thread
From: Akihiro Nagai @ 2011-03-23  7:29 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Ingo Molnar, Peter Zijlstra,
	Paul Mackerras
  Cc: linux-kernel, Masami Hiramatsu, 2nddept-manager, Akihiro Nagai,
	Masami Hiramatsu, Peter Zijlstra, Paul Mackerras, Ingo Molnar,
	Arnaldo Carvalho de Melo

builtin-top.c has an uninitialized valiable.
gcc(version 4.5.1) warns it and results in build failure.

# make
CC builtin-top.o
cc1: warnings being treated as errors
builtin-top.c: In function 'display_thread':
builtin-top.c:518:9: error: 'counter' may be used uninitialized in this function
builtin-top.c:518:9: note: 'counter' was declared here
make: *** [builtin-top.o] Error 1

Signed-off-by: Akihiro Nagai <akihiro.nagai.hw@hitachi.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
---

 tools/perf/builtin-top.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 70f1075..0e382ff 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -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 default event */
+				int counter = 0;
+
 				fprintf(stderr, "\nAvailable events:");
 
 				list_for_each_entry(top.sym_evsel, &top.evlist->entries, node)


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [tip:perf/urgent] perf top: Fix uninitialized 'counter' variable
  2011-03-23  7:29 [PATCH -tip ] [BUGFIX] perf-top: Fix uninitialized variable Akihiro Nagai
@ 2011-03-23  9:43 ` tip-bot for Akihiro Nagai
  0 siblings, 0 replies; 2+ messages in thread
From: tip-bot for Akihiro Nagai @ 2011-03-23  9:43 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, paulus, hpa, mingo, akihiro.nagai.hw, peterz,
	masami.hiramatsu.pt, acme, tglx, mingo

Commit-ID:  ce2d17ca7f85dcade62cd608601a0d52ccdaf0e6
Gitweb:     http://git.kernel.org/tip/ce2d17ca7f85dcade62cd608601a0d52ccdaf0e6
Author:     Akihiro Nagai <akihiro.nagai.hw@hitachi.com>
AuthorDate: Wed, 23 Mar 2011 16:29:39 +0900
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Wed, 23 Mar 2011 10:38:32 +0100

perf top: Fix uninitialized 'counter' variable

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>
---
 tools/perf/builtin-top.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 70f1075..676b4fb 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -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)

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-03-23  9:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-23  7:29 [PATCH -tip ] [BUGFIX] perf-top: Fix uninitialized variable Akihiro Nagai
2011-03-23  9:43 ` [tip:perf/urgent] perf top: Fix uninitialized 'counter' variable tip-bot for Akihiro Nagai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox