>From 64aa1504fe4838b9a9fe6dca151e23330e41b543 Mon Sep 17 00:00:00 2001 From: Daniel Santos Date: Fri, 4 May 2012 19:36:24 -0500 Subject: mm/slab.c: Fix build breakage when compiling -O0 BUILD_BUG_ON is more robust, detecting when we're not optimizing and, thus, when __builtin_constant_p will always return zero and produce a false-positive. Further, this distinguishes between the errors of size not being a compile-time constant and size just not being an accepted value. --- mm/slab.c | 10 ++++------ 1 files changed, 4 insertions(+), 6 deletions(-) diff --git a/mm/slab.c b/mm/slab.c index e901a36..1a618b2 100644 --- a/mm/slab.c +++ b/mm/slab.c @@ -308,10 +308,9 @@ static void cache_reap(struct work_struct *unused); */ static __always_inline int index_of(const size_t size) { - extern void __bad_size(void); + int i = 0; - if (__builtin_constant_p(size)) { - int i = 0; + BUILD_BUG_ON(!__builtin_constant_p(size)); #define CACHE(x) \ if (size <=x) \ @@ -320,9 +319,8 @@ static __always_inline int index_of(const size_t size) i++; #include #undef CACHE - __bad_size(); - } else - __bad_size(); + + BUILD_BUG(); /* bad size */ return 0; } -- 1.7.3.4