Skip to contentSkip to conversation

perf_event: fix compile error

PATCH In review Xiao Guangrong 2 participants 5 messages Dec 2, 2009 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf_event: fix compile error

cc1: warnings being treated as errors
builtin-probe.c: In function ‘cmd_probe’:
builtin-probe.c:163: error: unused variable ‘fd’

---
 tools/perf/builtin-probe.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
tools/perf/builtin-probe.c +2 -1
index b5d15cf..64ea038 100644
@@ -160,7 +160,8 @@ static const struct option options[] = {
 
 int cmd_probe(int argc, const char **argv, const char *prefix __used)
 {
-	int i, j, fd, ret;
+	int i, j, ret;
+	int fd __used;
 	struct probe_point *pp;
 
 	argc = parse_options(argc, argv, options, probe_usage,
Signature · 1 line
1.6.1.2
#1 lore raw
Quoted 14 lines · Xiao Guangrong

cc1: warnings being treated as errors builtin-probe.c: In function ???cmd_probe???:
builtin-probe.c:163: error: unused variable ???fd???

---
 tools/perf/builtin-probe.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
tools/perf/builtin-probe.c +0 -0
index b5d15cf..64ea038 100644

tools/perf/builtin-probe.c static const struct option options[] = { · line 165

Quoted 7 lines
tools/perf/builtin-probe.c +2 -1
@@ -160,7 +160,8 @@ static const struct option options[] = {
 
 int cmd_probe(int argc, const char **argv, const char *prefix __used)
 {
-	int i, j, fd, ret;
+	int i, j, ret;
+	int fd __used;
 	struct probe_point *pp;

i think it's better to initialize it to -1 instead of turning off the warning.

Ingo

#2 lore raw
Quoted 17 lines · Ingo Molnar
Quoted 15 lines · Xiao Guangrong

cc1: warnings being treated as errors builtin-probe.c: In function ???cmd_probe???:
builtin-probe.c:163: error: unused variable ???fd???

---
 tools/perf/builtin-probe.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
tools/perf/builtin-probe.c +0 -0
index b5d15cf..64ea038 100644
@@ -160,7 +160,8 @@ static const struct option options[] = {
 
Quoted 10 lines

tools/perf/builtin-probe.c static const struct option options[] = { · line 165

Quoted 6 lines
tools/perf/builtin-probe.c +2 -1
 int cmd_probe(int argc, const char **argv, const char *prefix __used)
 {
-	int i, j, fd, ret;
+	int i, j, ret;
+	int fd __used;
 	struct probe_point *pp;

i think it's better to initialize it to -1 instead of turning off the warning.

Hi Ingo,

I have try this way but the error still exists :-(

Thanks,
Xiao

#3 lore raw
Quoted 29 lines · Xiao Guangrong
Quoted 17 lines · Ingo Molnar
Quoted 15 lines · Xiao Guangrong

cc1: warnings being treated as errors builtin-probe.c: In function ???cmd_probe???:
builtin-probe.c:163: error: unused variable ???fd???

---
 tools/perf/builtin-probe.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
tools/perf/builtin-probe.c +0 -0
index b5d15cf..64ea038 100644
@@ -160,7 +160,8 @@ static const struct option options[] = {
 
Quoted 10 lines

tools/perf/builtin-probe.c static const struct option options[] = { · line 165

Quoted 6 lines
tools/perf/builtin-probe.c +2 -1
 int cmd_probe(int argc, const char **argv, const char *prefix __used)
 {
-	int i, j, fd, ret;
+	int i, j, ret;
+	int fd __used;
 	struct probe_point *pp;

i think it's better to initialize it to -1 instead of turning off the warning.

Quoted 3 lines

Hi Ingo,

I have try this way but the error still exists :-(

ah - unused, not uninitialized.

Then the right fix is to use NO_LIBDWARF, not __used annotation. I've changed it to that and committed your fix - thanks!

Ingo

#4 lore raw

[tip:perf/core] perf_event: Fix compile error

In reply to Xiao Guangrong
Commit-ID:  bdad0db7dbdb37d0bb3c7d0f65cd3ff599ea6ecb
Gitweb:     http://git.kernel.org/tip/bdad0db7dbdb37d0bb3c7d0f65cd3ff599ea6ecb
Author:     Xiao Guangrong <[email protected]>
AuthorDate: Wed, 2 Dec 2009 16:08:41 +0800
Committer:  Ingo Molnar <[email protected]>
CommitDate: Wed, 2 Dec 2009 09:27:01 +0100

perf_event: Fix compile error

Fix:

cc1: warnings being treated as errors
builtin-probe.c: In function 'cmd_probe':
builtin-probe.c:163: error: unused variable 'fd'

Cc Masami Hiramatsu <[email protected]>
Cc Peter Zijlstra <[email protected]>

LKML-Reference: <[email protected]>

[ v2: use NO_LIBDWARF instead of __used ]
---
 tools/perf/builtin-probe.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
tools/perf/builtin-probe.c +4 -1
index b5d15cf..a58e11b 100644
@@ -160,7 +160,10 @@ static const struct option options[] = {
 
 int cmd_probe(int argc, const char **argv, const char *prefix __used)
 {
-	int i, j, fd, ret;
+	int i, j, ret;
+#ifndef NO_LIBDWARF
+	int fd;
+#endif
 	struct probe_point *pp;
 
 	argc = parse_options(argc, argv, options, probe_usage,