Skip to contentSkip to conversation

perf: fix building warning on ARM 32.

PATCH Superseded Wang Nan 2 participants 3 messages Dec 16, 2014 perf events

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Wang Nan

author
#0 lore raw

PATCH 1/1 perf: fix building warning on ARM 32.

Commit 85c116a6c introduces asprintf() call and matches '%ld' to a u64 argument, which is incorrect on ARM.

CC /home/wn/util/srcline.o
util/srcline.c: In function 'get_srcline':
util/srcline.c:297:6: error: format '%ld' expects argument of type 'long int', but argument 4 has type 'u64' [-Werror=format]
cc1: all warnings being treated as errors
make[1]: *** [/home/wn/util/srcline.o] Error 1

---
 tools/perf/util/srcline.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/srcline.c +1 -1
index e73b6a5..42cb642 100644
@@ -294,7 +294,7 @@ out:
 	}
 	if (sym) {
 		if (asprintf(&srcline, "%s+%ld", show_sym ? sym->name : "",
-					addr - sym->start) < 0)
+					(long int)(addr - sym->start)) < 0)
 			return SRCLINE_UNKNOWN;
 	} else if (asprintf(&srcline, "%s[%lx]", dso->short_name, addr) < 0)
 		return SRCLINE_UNKNOWN;
Signature · 1 line
1.8.4
maintainer
#1 lore raw

Hi Wang,

Quoted 8 lines · Wang Nan

Commit 85c116a6c introduces asprintf() call and matches '%ld' to a u64 argument, which is incorrect on ARM.

CC /home/wn/util/srcline.o
util/srcline.c: In function 'get_srcline':
util/srcline.c:297:6: error: format '%ld' expects argument of type 'long int', but argument 4 has type 'u64' [-Werror=format]
cc1: all warnings being treated as errors
make[1]: *** [/home/wn/util/srcline.o] Error 1

Hmm.. shouldn't it be %PRIu64 instead?

Thanks,
Namhyung

Quoted 27 lines
---
 tools/perf/util/srcline.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/srcline.c +1 -1
index e73b6a5..42cb642 100644
@@ -294,7 +294,7 @@ out:
 	}
 	if (sym) {
 		if (asprintf(&srcline, "%s+%ld", show_sym ? sym->name : "",
-					addr - sym->start) < 0)
+					(long int)(addr - sym->start)) < 0)
 			return SRCLINE_UNKNOWN;
 	} else if (asprintf(&srcline, "%s[%lx]", dso->short_name, addr) < 0)
 		return SRCLINE_UNKNOWN;
Signature · 7 lines
1.8.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
author
#2 lore raw
Quoted 6 lines · Namhyung Kim

Hi Wang,

Quoted 3 lines · Wang Nan

Commit 85c116a6c introduces asprintf() call and matches '%ld' to a u64 argument, which is incorrect on ARM.

Quoted 8 lines
Quoted 5 lines

CC /home/wn/util/srcline.o
util/srcline.c: In function 'get_srcline':
util/srcline.c:297:6: error: format '%ld' expects argument of type 'long int', but argument 4 has type 'u64' [-Werror=format]
cc1: all warnings being treated as errors
make[1]: *** [/home/wn/util/srcline.o] Error 1

Hmm.. shouldn't it be %PRIu64 instead?

It is a difference between two addresses, and I believe the value should not be very large.

Anyway, I'll follow your advise if you prefer to use %PRIu64.

In addition, addr is 'unsigned long addr', sym->start is 'u64', the type if this expression is more or less obscure to readers. By investigating all caller of get_srcline(), I find that the type of 'addr' should be 'u64', not 'unsigned long'. So I'll post another patch which fixes param list of get_srcline() also.

Thanks.

Quoted 31 lines

Thanks,
Namhyung

Quoted 27 lines
---
 tools/perf/util/srcline.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/srcline.c +1 -1
index e73b6a5..42cb642 100644
@@ -294,7 +294,7 @@ out:
 	}
 	if (sym) {
 		if (asprintf(&srcline, "%s+%ld", show_sym ? sym->name : "",
-					addr - sym->start) < 0)
+					(long int)(addr - sym->start)) < 0)
 			return SRCLINE_UNKNOWN;
 	} else if (asprintf(&srcline, "%s[%lx]", dso->short_name, addr) < 0)
 		return SRCLINE_UNKNOWN;
Signature · 7 lines
1.8.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/