mm/slab.c: Fix build breakage when compiling -O0
From: Daniel Santos
Date: Fri May 04 2012 - 20:36:24 EST
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 <linux/kmalloc_sizes.h>
#undef CACHE
- __bad_size();
- } else
- __bad_size();
+
+ BUILD_BUG(); /* bad size */
return 0;
}
--
1.7.3.4
--------------060607080109090801050700--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/