lkml.org 
[lkml]   [2009]   [Nov]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] qnx4: Use hweight8
On 2009-11-13 08:06:18, Akinobu Mita wrote:
> Use hweight8 instead of counting for each bit
>
> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
> Cc: Anders Larsen <al@alarsen.net>
> Cc: Al Viro <viro@zeniv.linux.org.uk>

The original code counted the number of zeroes whereas hweight8() counts ones, so

NAK

(hint: "tot += 8 - hweight8(b)" should do the trick)

Cheers
Anders

> ---
> fs/qnx4/bitmap.c | 17 +----------------
> 1 files changed, 1 insertions(+), 16 deletions(-)
>
> diff --git a/fs/qnx4/bitmap.c b/fs/qnx4/bitmap.c
> index 0afba06..b913e3d 100644
> --- a/fs/qnx4/bitmap.c
> +++ b/fs/qnx4/bitmap.c
> @@ -35,22 +35,7 @@ static void count_bits(register const char *bmPart, register int size,
> }
> do {
> b = *bmPart++;
> - if ((b & 1) == 0)
> - tot++;
> - if ((b & 2) == 0)
> - tot++;
> - if ((b & 4) == 0)
> - tot++;
> - if ((b & 8) == 0)
> - tot++;
> - if ((b & 16) == 0)
> - tot++;
> - if ((b & 32) == 0)
> - tot++;
> - if ((b & 64) == 0)
> - tot++;
> - if ((b & 128) == 0)
> - tot++;
> + tot += hweight8(b);
> size--;
> } while (size != 0);
> *tf = tot;
> --
> 1.6.5.1



\
 
 \ /
  Last update: 2009-11-13 10:29    [from the cache]
©2003-2011 Jasper Spaans