Skip to contentSkip to conversation

perf x86: Fix compile of util/tsc.c

PATCH In review David Ahern 4 participants 4 messages Jul 26, 2013 – Aug 12, 2013 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf x86: Fix compile of util/tsc.c

On Fedora 18, with gcc 4.6.4 compile fails with:

arch/x86/util/tsc.c: In function ‘perf_time_to_tsc’:
arch/x86/util/tsc.c:13:6: error: declaration of ‘time’ shadows a global declaration [-Werror=shadow]
cc1: all warnings being treated as errors
make: *** [/tmp/junk/arch/x86/util/tsc.o] Error 1
make: *** Waiting for unfinished jobs....

Fix by renaming the local variable.

---
 tools/perf/arch/x86/util/tsc.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
tools/perf/arch/x86/util/tsc.c +4 -4
index f111744..9570c2b 100644
@@ -10,11 +10,11 @@
 
 u64 perf_time_to_tsc(u64 ns, struct perf_tsc_conversion *tc)
 {
-	u64 time, quot, rem;
+	u64 t, quot, rem;
 
-	time = ns - tc->time_zero;
-	quot = time / tc->time_mult;
-	rem  = time % tc->time_mult;
+	t = ns - tc->time_zero;
+	quot = t / tc->time_mult;
+	rem  = t % tc->time_mult;
 	return (quot << tc->time_shift) +
 	       (rem << tc->time_shift) / tc->time_mult;
 }
Signature · 1 line
1.7.10.1
reviewer Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · David Ahern

On Fedora 18, with gcc 4.6.4 compile fails with:

arch/x86/util/tsc.c: In function ‘perf_time_to_tsc’:
arch/x86/util/tsc.c:13:6: error: declaration of ‘time’ shadows a global declaration [-Werror=shadow]
cc1: all warnings being treated as errors
make: *** [/tmp/junk/arch/x86/util/tsc.o] Error 1
make: *** Waiting for unfinished jobs....

Quoted 4 lines

Fix by renaming the local variable.

Quoted 25 lines
---
 tools/perf/arch/x86/util/tsc.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
tools/perf/arch/x86/util/tsc.c +4 -4
index f111744..9570c2b 100644
@@ -10,11 +10,11 @@
 
 u64 perf_time_to_tsc(u64 ns, struct perf_tsc_conversion *tc)
 {
-	u64 time, quot, rem;
+	u64 t, quot, rem;
 
-	time = ns - tc->time_zero;
-	quot = time / tc->time_mult;
-	rem  = time % tc->time_mult;
+	t = ns - tc->time_zero;
+	quot = t / tc->time_mult;
+	rem  = t % tc->time_mult;
 	return (quot << tc->time_shift) +
 	       (rem << tc->time_shift) / tc->time_mult;
 }
Acked-by
#2 lore raw
Quoted 9 lines · Adrian Hunter
Quoted 8 lines · David Ahern

On Fedora 18, with gcc 4.6.4 compile fails with:

arch/x86/util/tsc.c: In function ‘perf_time_to_tsc’:
arch/x86/util/tsc.c:13:6: error: declaration of ‘time’ shadows a global declaration [-Werror=shadow]
cc1: all warnings being treated as errors
make: *** [/tmp/junk/arch/x86/util/tsc.o] Error 1
make: *** Waiting for unfinished jobs....

Quoted 6 lines
Quoted 4 lines

Fix by renaming the local variable.

#3 lore raw

[tip:perf/core] perf tools: Fix compile of util/tsc.c

In reply to David Ahern
perf tools: Fix compile of util/tsc.c
Commit-ID:  602bab1b883090ffd125ed1253fe8ec127c048b1
Gitweb:     http://git.kernel.org/tip/602bab1b883090ffd125ed1253fe8ec127c048b1
Author:     David Ahern <[email protected]>
AuthorDate: Fri, 26 Jul 2013 08:27:23 -0600
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Wed, 7 Aug 2013 17:35:24 -0300

perf tools: Fix compile of util/tsc.c

On Fedora 18, with gcc 4.6.4 compile fails with:

arch/x86/util/tsc.c: In function ‘perf_time_to_tsc’:
arch/x86/util/tsc.c:13:6: error: declaration of ‘time’ shadows a global declaration [-Werror=shadow]
cc1: all warnings being treated as errors
make: *** [/tmp/junk/arch/x86/util/tsc.o] Error 1
make: *** Waiting for unfinished jobs....

Fix by renaming the local variable.

---
 tools/perf/arch/x86/util/tsc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
tools/perf/arch/x86/util/tsc.c +4 -4
index f111744..9570c2b 100644
@@ -10,11 +10,11 @@
 
 u64 perf_time_to_tsc(u64 ns, struct perf_tsc_conversion *tc)
 {
-	u64 time, quot, rem;
+	u64 t, quot, rem;
 
-	time = ns - tc->time_zero;
-	quot = time / tc->time_mult;
-	rem  = time % tc->time_mult;
+	t = ns - tc->time_zero;
+	quot = t / tc->time_mult;
+	rem  = t % tc->time_mult;
 	return (quot << tc->time_shift) +
 	       (rem << tc->time_shift) / tc->time_mult;
 }