Skip to contentSkip to conversation

mm/slab.c: Fix build breakage when compiling -O0

PATCH New Daniel Santos 1 participant 1 message May 5, 2012 Memory management

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm/slab.c: Fix build breakage when compiling -O0

Quoted 1 line

From 64aa1504fe4838b9a9fe6dca151e23330e41b543 Mon Sep 17 00:00:00 2001

From: Daniel Santos <[email protected]>
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(-)
mm/slab.c +4 -6
index e901a36..1a618b2 100644
@@ -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;
 }
 
Signature · 1 line
1.7.3.4