Allow BUG_ON to be optimised away if it is a constant 0. Useful if we have some BUG_ONs who's conditions become a constant 0 when debugging functions are turned off. Signed-off-by: Nick Piggin Index: linux-2.6/include/asm-ppc64/bug.h =================================================================== --- linux-2.6.orig/include/asm-ppc64/bug.h +++ linux-2.6/include/asm-ppc64/bug.h @@ -38,13 +38,17 @@ struct bug_entry *find_bug(unsigned long } while (0) #define BUG_ON(x) do { \ - __asm__ __volatile__( \ - "1: tdnei %0,0\n" \ - ".section __bug_table,\"a\"\n\t" \ - " .llong 1b,%1,%2,%3\n" \ - ".previous" \ - : : "r" ((long long)(x)), "i" (__LINE__), \ - "i" (__FILE__), "i" (__FUNCTION__)); \ + if (__builtin_constant_p(x) && (x) == 0) \ + ; /* nothing */ \ + else { \ + __asm__ __volatile__( \ + "1: tdnei %0,0\n" \ + ".section __bug_table,\"a\"\n\t" \ + " .llong 1b,%1,%2,%3\n" \ + ".previous" \ + : : "r" ((long long)(x)), "i" (__LINE__), \ + "i" (__FILE__), "i" (__FUNCTION__)); \ + } \ } while (0) #define WARN_ON(x) do { \