Skip to contentSkip to conversation

tools/perf: fix build when WERROR=1

PATCH In review Andy Shevchenko 2 participants 7 messages Aug 8, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools/perf: fix build when WERROR=1

util/symbol.c: In function ‘hex2u64’:
util/symbol.c:2836:2: error: passing argument 2 of ‘strtoull’ from incompatible pointer type [-Werror] In file included from util/symbol.c:3:0:
/usr/include/stdlib.h:215:31: note: expected ‘char ** restrict’ but argument is of type ‘const char **’
cc1: all warnings being treated as errors
make[1]: *** [util/symbol.o] Error 1
make[1]: Leaving directory `/home/andy/prj/linux-2.6/tools/perf'
make: *** [perf] Error 2

---
 tools/perf/util/symbol.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/symbol.c +1 -1
index ba2a489..26e695c 100644
@@ -2831,7 +2831,7 @@ int machines__create_kernel_maps(struct rb_root *machines, pid_t pid)
  */
 int hex2u64(const char *ptr, u64 *long_val)
 {
-	const char *p = ptr;
+	char *p;
 
 	*long_val = strtoull(ptr, &p, 16);
 
Signature · 1 line
1.7.10.4
#1 lore raw

Em Wed, Aug 08, 2012 at 06:05:50PM +0300, Andy Shevchenko escreveu:

Quoted 19 lines

util/symbol.c: In function ‘hex2u64’:
util/symbol.c:2836:2: error: passing argument 2 of ‘strtoull’ from incompatible pointer type [-Werror] In file included from util/symbol.c:3:0:
/usr/include/stdlib.h:215:31: note: expected ‘char ** restrict’ but argument is of type ‘const char **’
cc1: all warnings being treated as errors
make[1]: *** [util/symbol.o] Error 1
make[1]: Leaving directory `/home/andy/prj/linux-2.6/tools/perf'
make: *** [perf] Error 2

---
 tools/perf/util/symbol.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/symbol.c +0 -0
index ba2a489..26e695c 100644

tools/perf/util/symbol.c int machines__create_kernel_maps(struct rb_root *machines, pid_t pid) · line 2836

Quoted 7 lines
tools/perf/util/symbol.c +1 -1
@@ -2831,7 +2831,7 @@ int machines__create_kernel_maps(struct rb_root *machines, pid_t pid)
  */
 int hex2u64(const char *ptr, u64 *long_val)
 {
-	const char *p = ptr;
+	char *p;
 
 	*long_val = strtoull(ptr, &p, 16);

What tree is this against? Here I have:

/*
* While we find nice hex chars, build a long_val.
* Return number of chars processed.
*/
int hex2u64(const char *ptr, u64 *long_val)

{
        const char *p = ptr;
        *long_val = 0;

        while (*p) {
                const int hex_val = hex(*p);

                if (hex_val < 0)
                        break;

                *long_val = (*long_val << 4) | hex_val;
                p++;
        }

        return p - ptr;
}

- Arnaldo

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

Em Wed, Aug 08, 2012 at 06:05:50PM +0300, Andy Shevchenko escreveu:

Quoted 25 lines

util/symbol.c: In function ‘hex2u64’:
util/symbol.c:2836:2: error: passing argument 2 of ‘strtoull’ from incompatible pointer type [-Werror] In file included from util/symbol.c:3:0:
/usr/include/stdlib.h:215:31: note: expected ‘char ** restrict’ but argument is of type ‘const char **’
cc1: all warnings being treated as errors
make[1]: *** [util/symbol.o] Error 1
make[1]: Leaving directory `/home/andy/prj/linux-2.6/tools/perf'
make: *** [perf] Error 2

---
 tools/perf/util/symbol.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/symbol.c +1 -1
index ba2a489..26e695c 100644
@@ -2831,7 +2831,7 @@ int machines__create_kernel_maps(struct rb_root *machines, pid_t pid)
  */
 int hex2u64(const char *ptr, u64 *long_val)
 {
-	const char *p = ptr;
+	char *p;
 
Quoted 3 lines

tools/perf/util/symbol.c int machines__create_kernel_maps(struct rb_root *machines, pid_t pid) · line 2836

Quoted 1 line
tools/perf/util/symbol.c +0 -0
 	*long_val = strtoull(ptr, &p, 16);

What tree is this against? Here I have:

Ah, it's a fix on top on mine other fix.
I'll resend squashed version soon.

Quoted 24 lines

/*
* While we find nice hex chars, build a long_val.
* Return number of chars processed.
*/
int hex2u64(const char *ptr, u64 *long_val)

{
        const char *p = ptr;
        *long_val = 0;

        while (*p) {
                const int hex_val = hex(*p);

                if (hex_val < 0)
                        break;

                *long_val = (*long_val << 4) | hex_val;
                p++;
        }

        return p - ptr;
}

- Arnaldo

Signature · 2 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy
#6 lore raw

PATCH 1/1 tools/perf: remove yet another strtoull()

In reply to Arnaldo Carvalho de Melo
Cc Arnaldo Carvalho de Melo <[email protected]>
---
 tools/perf/util/symbol.c |   24 ++----------------------
 1 file changed, 2 insertions(+), 22 deletions(-)
tools/perf/util/symbol.c +2 -22
index 8b63b67..26e695c 100644
@@ -2825,35 +2825,15 @@ int machines__create_kernel_maps(struct rb_root *machines, pid_t pid)
 	return machine__create_kernel_maps(machine);
 }
 
-static int hex(char ch)
-{
-	if ((ch >= '0') && (ch <= '9'))
-		return ch - '0';
-	if ((ch >= 'a') && (ch <= 'f'))
-		return ch - 'a' + 10;
-	if ((ch >= 'A') && (ch <= 'F'))
-		return ch - 'A' + 10;
-	return -1;
-}
-
 /*
  * While we find nice hex chars, build a long_val.
  * Return number of chars processed.
  */
 int hex2u64(const char *ptr, u64 *long_val)
 {
-	const char *p = ptr;
-	*long_val = 0;
-
-	while (*p) {
-		const int hex_val = hex(*p);
+	char *p;
 
-		if (hex_val < 0)
-			break;
-
-		*long_val = (*long_val << 4) | hex_val;
-		p++;
-	}
+	*long_val = strtoull(ptr, &p, 16);
 
 	return p - ptr;
 }
Signature · 1 line
1.7.10.4
#3 lore raw
In reply to Andy Shevchenko

Em Wed, Aug 08, 2012 at 07:32:46PM +0300, Andy Shevchenko escreveu:

Quoted 10 lines · Arnaldo Carvalho de Melo
Quoted 7 lines

tools/perf/util/symbol.c int machines__create_kernel_maps(struct rb_root *machines, pid_t pid) · line 2836

Quoted 5 lines

{

tools/perf/util/symbol.c +1 -1
-	const char *p = ptr;
+	char *p;
 
 	*long_val = strtoull(ptr, &p, 16);

What tree is this against? Here I have:

Ah, it's a fix on top on mine other fix.
I'll resend squashed version soon.

But are you having trouble with the current implementation of hex2u64?

- Arnaldo

#4 lore raw
Quoted 3 lines · Arnaldo Carvalho de Melo
Quoted 2 lines

Ah, it's a fix on top on mine other fix.
I'll resend squashed version soon.

But are you having trouble with the current implementation of hex2u64?

Actually it's a clean up.

Signature · 2 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy
#5 lore raw

Em Wed, Aug 08, 2012 at 07:47:22PM +0300, Andy Shevchenko escreveu:

Quoted 6 lines · Arnaldo Carvalho de Melo
Quoted 3 lines
Quoted 2 lines

Ah, it's a fix on top on mine other fix.
I'll resend squashed version soon.

But are you having trouble with the current implementation of hex2u64?

Actually it's a clean up.

Ok, fair enough, will get it in my next round,

- Arnaldo