Commit ea4e0b5b authored by Matthew Dobson's avatar Matthew Dobson Committed by Christoph Hellwig

[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.
parent 3fa327f8
...@@ -4,10 +4,12 @@ ...@@ -4,10 +4,12 @@
#ifdef __KERNEL__ #ifdef __KERNEL__
#include <linux/config.h> #include <linux/config.h>
#define BITS_TO_LONGS(bits) \
(((bits)+BITS_PER_LONG-1)/BITS_PER_LONG)
#define DECLARE_BITMAP(name,bits) \ #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) \ #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 #endif
#include <linux/posix_types.h> #include <linux/posix_types.h>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment