Allow BUG_ON to be optimised away if it is a constant 0. Useful if we have some BUG_ONs with conditions that become a constant 0 when debugging functions are turned off. Signed-off-by: Nick Piggin Index: linux-2.6/include/asm-powerpc/bug.h =================================================================== --- linux-2.6.orig/include/asm-powerpc/bug.h +++ linux-2.6/include/asm-powerpc/bug.h @@ -40,24 +40,26 @@ struct bug_entry *find_bug(unsigned long } while (0) #define BUG_ON(x) do { \ - __asm__ __volatile__( \ - "1: "PPC_TLNEI" %0,0\n" \ - ".section __bug_table,\"a\"\n" \ - "\t"PPC_LONG" 1b,%1,%2,%3\n" \ - ".previous" \ - : : "r" ((long)(x)), "i" (__LINE__), \ - "i" (__FILE__), "i" (__FUNCTION__)); \ + if (!__builtin_constant_p(x) || (x)) \ + __asm__ __volatile__( \ + "1: "PPC_TLNEI" %0,0\n" \ + ".section __bug_table,\"a\"\n" \ + "\t"PPC_LONG" 1b,%1,%2,%3\n" \ + ".previous" \ + : : "r" ((long)(x)), "i" (__LINE__), \ + "i" (__FILE__), "i" (__FUNCTION__));\ } while (0) #define WARN_ON(x) do { \ - __asm__ __volatile__( \ - "1: "PPC_TLNEI" %0,0\n" \ - ".section __bug_table,\"a\"\n" \ - "\t"PPC_LONG" 1b,%1,%2,%3\n" \ - ".previous" \ - : : "r" ((long)(x)), \ - "i" (__LINE__ + BUG_WARNING_TRAP), \ - "i" (__FILE__), "i" (__FUNCTION__)); \ + if (!__builtin_constant_p(x) || (x)) \ + __asm__ __volatile__( \ + "1: "PPC_TLNEI" %0,0\n" \ + ".section __bug_table,\"a\"\n" \ + "\t"PPC_LONG" 1b,%1,%2,%3\n" \ + ".previous" \ + : : "r" ((long)(x)), \ + "i" (__LINE__ + BUG_WARNING_TRAP), \ + "i" (__FILE__), "i" (__FUNCTION__));\ } while (0) #define HAVE_ARCH_BUG