diff options
| author | Steven Rostedt <[email protected]> | 2006-02-01 03:05:44 -0800 |
|---|---|---|
| committer | Linus Torvalds <[email protected]> | 2006-02-01 08:53:17 -0800 |
| commit | 5ec8a847bb8ae2ba6395cfb7cb4bfdc78ada82ed (patch) | |
| tree | 2ef8bf7484700b49bae1b3c1191e04a80b78b102 | |
| parent | 18f820f655ce93b1e4d9b48fc6fcafc64157c6bc (diff) | |
[PATCH] slab: have index_of bug at compile time
I noticed the code for index_of is a creative way of finding the cache
index using the compiler to optimize to a single hard coded number. But
I couldn't help noticing that it uses two methods to let you know that
someone used it wrong. One is at compile time (the correct way), and
the other is at run time (not good).
Signed-off-by: Steven Rostedt <[email protected]>
Acked-by: Manfred Spraul <[email protected]>
Signed-off-by: Pekka Enberg <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
| -rw-r--r-- | mm/slab.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/mm/slab.c b/mm/slab.c index bb7a9837b949..613d385519fe 100644 --- a/mm/slab.c +++ b/mm/slab.c @@ -316,6 +316,8 @@ struct kmem_list3 __initdata initkmem_list3[NUM_INIT_LISTS]; */ static __always_inline int index_of(const size_t size) { + extern void __bad_size(void); + if (__builtin_constant_p(size)) { int i = 0; @@ -326,12 +328,9 @@ static __always_inline int index_of(const size_t size) i++; #include "linux/kmalloc_sizes.h" #undef CACHE - { - extern void __bad_size(void); - __bad_size(); - } + __bad_size(); } else - BUG(); + __bad_size(); return 0; } |