From: Daniel Santos <danielfsantos@att.net>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] mm/slab.c: Fix build breakage when compiling -O0
Date: Sat, 05 May 2012 04:52:02 -0500 [thread overview]
Message-ID: <4FA4F842.2080601@att.net> (raw)
[-- 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
reply other threads:[~2012-05-05 9:58 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4FA4F842.2080601@att.net \
--to=danielfsantos@att.net \
--cc=daniel.santos@pobox.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome