All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf: fix building warning on ARM 32.
@ 2014-12-16  2:10 Wang Nan
  2014-12-16  4:49 ` Namhyung Kim
  0 siblings, 1 reply; 3+ messages in thread
From: Wang Nan @ 2014-12-16  2:10 UTC (permalink / raw)
  To: a.p.zijlstra, paulus, mingo, acme, ak, namhyung; +Cc: lizefan, linux-kernel

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

Signed-off-by: Wang Nan <wangnan0@huawei.com>
---
 tools/perf/util/srcline.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/srcline.c b/tools/perf/util/srcline.c
index e73b6a5..42cb642 100644
--- a/tools/perf/util/srcline.c
+++ b/tools/perf/util/srcline.c
@@ -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;
-- 
1.8.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] perf: fix building warning on ARM 32.
  2014-12-16  2:10 [PATCH] perf: fix building warning on ARM 32 Wang Nan
@ 2014-12-16  4:49 ` Namhyung Kim
  2014-12-16  5:47   ` Wang Nan
  0 siblings, 1 reply; 3+ messages in thread
From: Namhyung Kim @ 2014-12-16  4:49 UTC (permalink / raw)
  To: Wang Nan; +Cc: a.p.zijlstra, paulus, mingo, acme, ak, lizefan, linux-kernel

Hi Wang,

On Tue, Dec 16, 2014 at 10:10:10AM +0800, Wang Nan wrote:
> 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


> 
> Signed-off-by: Wang Nan <wangnan0@huawei.com>
> ---
>  tools/perf/util/srcline.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/perf/util/srcline.c b/tools/perf/util/srcline.c
> index e73b6a5..42cb642 100644
> --- a/tools/perf/util/srcline.c
> +++ b/tools/perf/util/srcline.c
> @@ -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;
> -- 
> 1.8.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] perf: fix building warning on ARM 32.
  2014-12-16  4:49 ` Namhyung Kim
@ 2014-12-16  5:47   ` Wang Nan
  0 siblings, 0 replies; 3+ messages in thread
From: Wang Nan @ 2014-12-16  5:47 UTC (permalink / raw)
  To: Namhyung Kim; +Cc: a.p.zijlstra, paulus, mingo, acme, ak, lizefan, linux-kernel

On 2014/12/16 12:49, Namhyung Kim wrote:
> Hi Wang,
> 
> On Tue, Dec 16, 2014 at 10:10:10AM +0800, Wang Nan wrote:
>> 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?
> 

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.

> Thanks,
> Namhyung
> 
> 
>>
>> Signed-off-by: Wang Nan <wangnan0@huawei.com>
>> ---
>>  tools/perf/util/srcline.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/tools/perf/util/srcline.c b/tools/perf/util/srcline.c
>> index e73b6a5..42cb642 100644
>> --- a/tools/perf/util/srcline.c
>> +++ b/tools/perf/util/srcline.c
>> @@ -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;
>> -- 
>> 1.8.4
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>> Please read the FAQ at  http://www.tux.org/lkml/



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-12-16  5:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-16  2:10 [PATCH] perf: fix building warning on ARM 32 Wang Nan
2014-12-16  4:49 ` Namhyung Kim
2014-12-16  5:47   ` Wang Nan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.