On Wed, Mar 28, 2007 at 09:03:09AM +0530, Milind Arun Choudhary wrote:There were a discussion on this, at KJ, when BIT was first used with a modular operation. I said the same thing as you do now, but a big user of BIT is the input-subsystem who defined their BIT as above. Also it was mentioned that the compiler can only find the statical errors, a variable input can break it in runtime.
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -8,6 +8,9 @@
*/
#include <asm/bitops.h>
+#define BIT(nr) (1UL << ((nr) % BITS_PER_LONG))
I think this would be a disaster because something like
BIT(123)
would not even generate a warning.