lkml.org 
[lkml]   [2012]   [Aug]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH 3/3] perf tools: Fix a misuse of for_each_set_bit() in session.c
Date
Hi,

On Mon, 27 Aug 2012 15:38:27 +0800, Feng Tang wrote:
> In regs_dump__printf() it use for_each_set_bit() for bit ops by
> casting a (u64 *) to a (unsigned long *), this works for 64 bits
> machine, but will fail on 32 bits ones.
>
> Fix it by using the raw bit comparing method.

Did it really cause a build failure or a program error? If not, it
looks better to keep using for_each_set_bit() interface. How about
casting the @mask to (void *) ?

Thanks,
Namhyung


>
> Signed-off-by: Feng Tang <feng.tang@intel.com>
> ---
> tools/perf/util/session.c | 9 ++++-----
> 1 files changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
> index f7bb7ae..afcea6c 100644
> --- a/tools/perf/util/session.c
> +++ b/tools/perf/util/session.c
> @@ -904,11 +904,10 @@ static void regs_dump__printf(u64 mask, u64 *regs)
> {
> unsigned rid, i = 0;
>
> - for_each_set_bit(rid, (unsigned long *) &mask, sizeof(mask) * 8) {
> - u64 val = regs[i++];
> -
> - printf(".... %-5s 0x%" PRIx64 "\n",
> - perf_reg_name(rid), val);
> + for (rid = 0; rid < 64; rid++) {
> + if (mask & (1 << rid))
> + printf(".... %-5s 0x%" PRIx64 "\n",
> + perf_reg_name(rid), regs[i++]);
> }
> }


\
 
 \ /
  Last update: 2012-08-27 10:41    [W:0.107 / U:0.968 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site