Skip to contentSkip to conversation

sparc: clear bitmap correctly in bit_map_init()

PATCH In review Akinobu Mita 2 participants 2 messages Mar 24, 2013 – Mar 25, 2013 SPARC + UltraSPARC (sparc/sparc64)

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 sparc: clear bitmap correctly in bit_map_init()

In bit_map_init(), it attempts to clear all bits in the bitmap by memset(), but if the size of bitmap is not a multiple of the sizeof(long), it can't clear the trailing edge of bitmap properly on big-endian architecture. So it should use bitmap_clear() instead of memset().

There are only two users of bit_map_init(), and both of them don't cause the issue described above. But it would be better to fix it now for future changes.

---
 arch/sparc/lib/bitext.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
arch/sparc/lib/bitext.c +1 -5
index d516fda..04d8bad 100644
@@ -111,11 +111,7 @@ void bit_map_clear(struct bit_map *t, int offset, int len)
 
 void bit_map_init(struct bit_map *t, unsigned long *map, int size)
 {
-
-	if ((size & 07) != 0)
-		BUG();
-	memset(map, 0, size>>3);
-
+	bitmap_zero(map, size);
 	memset(t, 0, sizeof *t);
 	spin_lock_init(&t->lock);
 	t->map = map;
Signature · 1 line
1.8.1.4
maintainer
#1 lore raw

From: Akinobu Mita <[email protected]>
Date: Sun, 24 Mar 2013 17:55:04 +0900

Quoted 10 lines

In bit_map_init(), it attempts to clear all bits in the bitmap by memset(), but if the size of bitmap is not a multiple of the sizeof(long), it can't clear the trailing edge of bitmap properly on big-endian architecture. So it should use bitmap_clear() instead of memset().

There are only two users of bit_map_init(), and both of them don't cause the issue described above. But it would be better to fix it now for future changes.

I'd rather not spend time fixing non-bugs.

Sorry, I'm not applying this.