lkml.org 
[lkml]   [2012]   [Aug]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 3/3] perf tools: Fix a misuse of for_each_set_bit() in session.c
Date
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.

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++]);
}
}

--
1.7.1


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