From ea4e0b5bc6a86a370d5b7089af4d9aa901cecf9c Mon Sep 17 00:00:00 2001 From: Matthew Dobson Date: Wed, 5 Feb 2003 22:55:32 -0800 Subject: [PATCH] Broken CLEAR_BITMAP() macro The CLEAR_BITMAP() macro in include/linux/types.h is broken and doesn't round the bitmap size to the proper 'long' boundary. This fixes it by creating a macro BITS_TO_LONGS that just rounds a number of bits up to the closest number of unsigned longs. This makes the DECLARE & CLEAR _BITMAP macros more readable and fixes the bug. --- include/linux/types.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'include/linux') diff --git a/include/linux/types.h b/include/linux/types.h index 94ceb057eb64..f1c0ce5eb845 100644 --- a/include/linux/types.h +++ b/include/linux/types.h @@ -4,10 +4,12 @@ #ifdef __KERNEL__ #include +#define BITS_TO_LONGS(bits) \ + (((bits)+BITS_PER_LONG-1)/BITS_PER_LONG) #define DECLARE_BITMAP(name,bits) \ - unsigned long name[((bits)+BITS_PER_LONG-1)/BITS_PER_LONG] + unsigned long name[BITS_TO_LONGS(bits)] #define CLEAR_BITMAP(name,bits) \ - memset(name, 0, ((bits)+BITS_PER_LONG-1)/8) + memset(name, 0, BITS_TO_LONGS(bits)*sizeof(unsigned long)) #endif #include -- cgit v1.2.3