Skip to contentSkip to conversation

perf tools: Shut up compiler warning

PATCH In review Arnaldo Carvalho de Melo 3 participants 3 messages Oct 19, 2009 – Oct 20, 2009 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf tools: Shut up compiler warning

cc1: warnings being treated as errors
util/trace-event-parse.c: In function ‘parse_ftrace_printk’:
util/trace-event-parse.c:289: warning: ‘fmt’ may be used uninitialized in this function

Cc Steven Rostedt <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Frederic Weisbecker <[email protected]>
---
 tools/perf/util/trace-event-parse.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
tools/perf/util/trace-event-parse.c +1 -1
index 4b61b49..0b8a01b 100644
@@ -286,7 +286,7 @@ void parse_ftrace_printk(char *file, unsigned int size __unused)
 	char *line;
 	char *next = NULL;
 	char *addr_str;
-	char *fmt;
+	char *fmt = NULL;
 	int i;
 
 	line = strtok_r(file, "\n", &next);
Signature · 1 line
1.5.5.1
#1 lore raw
Quoted 17 lines · Arnaldo Carvalho de Melo

cc1: warnings being treated as errors
util/trace-event-parse.c: In function ‘parse_ftrace_printk’:
util/trace-event-parse.c:289: warning: ‘fmt’ may be used uninitialized in this function

Cc Steven Rostedt <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Frederic Weisbecker <[email protected]>
---
 tools/perf/util/trace-event-parse.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
tools/perf/util/trace-event-parse.c +0 -0
index 4b61b49..0b8a01b 100644

tools/perf/util/trace-event-parse.c void parse_ftrace_printk(char *file, unsigned int size __unused) · line 292

Quoted 8 lines
tools/perf/util/trace-event-parse.c +1 -1
@@ -286,7 +286,7 @@ void parse_ftrace_printk(char *file, unsigned int size __unused)
 	char *line;
 	char *next = NULL;
 	char *addr_str;
-	char *fmt;
+	char *fmt = NULL;
 	int i;
 
 	line = strtok_r(file, "\n", &next);

Actually, this might be a real bug that GCC pointed out: what makes sure that strtok_r() does not return a NULL (no more tokens) and hence fmt remains NULL (crashing the rest of the parser)?

Ingo

#2 lore raw
Quoted 26 lines · Ingo Molnar
Quoted 24 lines · Arnaldo Carvalho de Melo

cc1: warnings being treated as errors
util/trace-event-parse.c: In function ‘parse_ftrace_printk’:
util/trace-event-parse.c:289: warning: ‘fmt’ may be used uninitialized in this function

Cc Steven Rostedt <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Frederic Weisbecker <[email protected]>
---
 tools/perf/util/trace-event-parse.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
tools/perf/util/trace-event-parse.c +1 -1
index 4b61b49..0b8a01b 100644
@@ -286,7 +286,7 @@ void parse_ftrace_printk(char *file, unsigned int size __unused)
 	char *line;
 	char *next = NULL;
 	char *addr_str;
-	char *fmt;
+	char *fmt = NULL;
 	int i;
 
Quoted 5 lines

tools/perf/util/trace-event-parse.c void parse_ftrace_printk(char *file, unsigned int size __unused) · line 292

Quoted 1 line
tools/perf/util/trace-event-parse.c +0 -0
 	line = strtok_r(file, "\n", &next);

Actually, this might be a real bug that GCC pointed out: what makes sure that strtok_r() does not return a NULL (no more tokens) and hence fmt remains NULL (crashing the rest of the parser)?

Ug, yeah that's a bug. That was one of the later changes I did at night. I'll go look at it and see how it should really be.

Thanks,

-- Steve