Skip to contentSkip to conversation

qnx4: Use hweight8

PATCH Superseded Akinobu Mita 2 participants 4 messages Nov 13, 2009 QNX4 filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qnx4: Use hweight8

Use hweight8 instead of counting for each bit

Cc Anders Larsen <[email protected]>
Cc Al Viro <[email protected]>
---
 fs/qnx4/bitmap.c |   17 +----------------
 1 files changed, 1 insertions(+), 16 deletions(-)
fs/qnx4/bitmap.c +1 -16
index 0afba06..b913e3d 100644
@@ -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;
Signature · 1 line
1.6.5.1
maintainer NAK
#1 lore raw
Quoted 5 lines · Akinobu Mita

Use hweight8 instead of counting for each bit

Cc Anders Larsen <[email protected]>
Cc Al Viro <[email protected]>

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

Quoted 34 lines
---
 fs/qnx4/bitmap.c |   17 +----------------
 1 files changed, 1 insertions(+), 16 deletions(-)
fs/qnx4/bitmap.c +1 -16
index 0afba06..b913e3d 100644
@@ -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;
Signature · 1 line
1.6.5.1
#2 lore raw

PATCH v2 1/1 qnx4: Use hweight8

Quoted 5 lines

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]

Cc Anders Larsen <[email protected]>
Cc Al Viro <[email protected]>
---
 fs/qnx4/bitmap.c |   17 +----------------
 1 files changed, 1 insertions(+), 16 deletions(-)
fs/qnx4/bitmap.c +1 -16
index 0afba06..cbaae72 100644
@@ -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;
Signature · 1 line
1.6.5.1
maintainer Acked-by on v2 1/1
#3 lore raw
Quoted 11 lines · Akinobu Mita

Oops,

Subject: [PATCH v2] qnx4: Use hweight8

Use hweight8 instead of counting for each bit

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

Cc Anders Larsen <[email protected]>
Cc Al Viro <[email protected]>
Quoted 34 lines
---
 fs/qnx4/bitmap.c |   17 +----------------
 1 files changed, 1 insertions(+), 16 deletions(-)
fs/qnx4/bitmap.c +1 -16
index 0afba06..cbaae72 100644
@@ -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;
Signature · 1 line
1.6.5.1