lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 27 Aug 2012 16:59:07 +0900
From:	Namhyung Kim <namhyung@...nel.org>
To:	Feng Tang <feng.tang@...el.com>
Cc:	acme@...hat.com, mingo@...e.hu, a.p.zijlstra@...llo.nl,
	dsahern@...il.com, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 3/3] perf tools: Fix a misuse of for_each_set_bit() in session.c

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@...el.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++]);
>  	}
>  }
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ