* [PATCH] mm/slab.c: Fix build breakage when compiling -O0
@ 2012-05-05 9:52 Daniel Santos
0 siblings, 0 replies; only message in thread
From: Daniel Santos @ 2012-05-05 9:52 UTC (permalink / raw)
To: linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1 bytes --]
[-- Attachment #2: 0001-mm-slab.c-Fix-build-breakage-when-compiling-O0.patch --]
[-- Type: text/x-patch, Size: 1239 bytes --]
>From 64aa1504fe4838b9a9fe6dca151e23330e41b543 Mon Sep 17 00:00:00 2001
From: Daniel Santos <daniel.santos@pobox.com>
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 <linux/kmalloc_sizes.h>
#undef CACHE
- __bad_size();
- } else
- __bad_size();
+
+ BUILD_BUG(); /* bad size */
return 0;
}
--
1.7.3.4
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2012-05-05 9:58 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-05 9:52 [PATCH] mm/slab.c: Fix build breakage when compiling -O0 Daniel Santos
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.