mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] qnx4: Use hweight8
@ 2009-11-13  7:06 Akinobu Mita
  2009-11-13  9:25 ` Anders Larsen
  0 siblings, 1 reply; 4+ messages in thread
From: Akinobu Mita @ 2009-11-13  7:06 UTC (permalink / raw)
  To: akpm, linux-kernel; +Cc: Akinobu Mita, Anders Larsen, Al Viro

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>
---
 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


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

* Re: [PATCH] qnx4: Use hweight8
  2009-11-13  7:06 [PATCH] qnx4: Use hweight8 Akinobu Mita
@ 2009-11-13  9:25 ` Anders Larsen
  2009-11-13  9:57   ` [PATCH v2] " Akinobu Mita
  0 siblings, 1 reply; 4+ messages in thread
From: Anders Larsen @ 2009-11-13  9:25 UTC (permalink / raw)
  To: Akinobu Mita; +Cc: akpm, linux-kernel, Akinobu Mita, Al Viro

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


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

* [PATCH v2] qnx4: Use hweight8
  2009-11-13  9:25 ` Anders Larsen
@ 2009-11-13  9:57   ` Akinobu Mita
  2009-11-13 10:11     ` Anders Larsen
  0 siblings, 1 reply; 4+ messages in thread
From: Akinobu Mita @ 2009-11-13  9:57 UTC (permalink / raw)
  To: akpm, linux-kernel; +Cc: Akinobu Mita, Anders Larsen, Al Viro

> The original code counted the number of zeroes whereas hweight8() counts ones, so
>
> NAK
>
> (hint: "tot += 8 - hweight8(b)" should do the trick)

Oops,

Subject: [PATCH v2] qnx4: Use hweight8

Use hweight8 instead of counting for each bit

[ v2: count_bit() counts zero bits in the bitmap]

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Anders Larsen <al@alarsen.net>
Cc: Al Viro <viro@zeniv.linux.org.uk>
---
 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..cbaae72 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 += 8 - hweight8(b);
 		size--;
 	} while (size != 0);
 	*tf = tot;
-- 
1.6.5.1


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

* Re: [PATCH v2] qnx4: Use hweight8
  2009-11-13  9:57   ` [PATCH v2] " Akinobu Mita
@ 2009-11-13 10:11     ` Anders Larsen
  0 siblings, 0 replies; 4+ messages in thread
From: Anders Larsen @ 2009-11-13 10:11 UTC (permalink / raw)
  To: Akinobu Mita; +Cc: akpm, linux-kernel, Akinobu Mita, Al Viro

On 2009-11-13 10:57:45, Akinobu Mita wrote:
> Oops,
> 
> Subject: [PATCH v2] qnx4: Use hweight8
> 
> Use hweight8 instead of counting for each bit
> 
> [ v2: count_bit() counts zero bits in the bitmap]
> 
> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
> Cc: Anders Larsen <al@alarsen.net>
> Cc: Al Viro <viro@zeniv.linux.org.uk>

Acked-by: Anders Larsen <al@alarsen.net>

> ---
>  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..cbaae72 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 += 8 - hweight8(b);
>  		size--;
>  	} while (size != 0);
>  	*tf = tot;
> -- 
> 1.6.5.1


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

end of thread, other threads:[~2009-11-13 10:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-13  7:06 [PATCH] qnx4: Use hweight8 Akinobu Mita
2009-11-13  9:25 ` Anders Larsen
2009-11-13  9:57   ` [PATCH v2] " Akinobu Mita
2009-11-13 10:11     ` Anders Larsen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®