* [PATCH] tile: replace some BUG_ON checks with BUILD_BUG_ON checks
@ 2010-10-05 15:55 Akinobu Mita
2010-10-05 16:50 ` Chris Metcalf
0 siblings, 1 reply; 2+ messages in thread
From: Akinobu Mita @ 2010-10-05 15:55 UTC (permalink / raw)
To: linux-kernel; +Cc: Akinobu Mita, Chris Metcalf
Some BUG_ON checks can be detected at compile time rather than
at runtime.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Chris Metcalf <cmetcalf@tilera.com>
---
This patch is not compile tested.
arch/tile/lib/atomic_32.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/tile/lib/atomic_32.c b/arch/tile/lib/atomic_32.c
index 8040b42..7a5cc70 100644
--- a/arch/tile/lib/atomic_32.c
+++ b/arch/tile/lib/atomic_32.c
@@ -300,7 +300,7 @@ void __init __init_atomic_per_cpu(void)
#else /* ATOMIC_LOCKS_FOUND_VIA_TABLE() */
/* Validate power-of-two and "bigger than cpus" assumption */
- BUG_ON(ATOMIC_HASH_SIZE & (ATOMIC_HASH_SIZE-1));
+ BUILD_BUG_ON(ATOMIC_HASH_SIZE & (ATOMIC_HASH_SIZE-1));
BUG_ON(ATOMIC_HASH_SIZE < nr_cpu_ids);
/*
@@ -314,17 +314,17 @@ void __init __init_atomic_per_cpu(void)
BUG_ON((unsigned long)atomic_locks % PAGE_SIZE != 0);
/* The locks must all fit on one page. */
- BUG_ON(ATOMIC_HASH_SIZE * sizeof(int) > PAGE_SIZE);
+ BUILD_BUG_ON(ATOMIC_HASH_SIZE * sizeof(int) > PAGE_SIZE);
/*
* We use the page offset of the atomic value's address as
* an index into atomic_locks, excluding the low 3 bits.
* That should not produce more indices than ATOMIC_HASH_SIZE.
*/
- BUG_ON((PAGE_SIZE >> 3) > ATOMIC_HASH_SIZE);
+ BUILD_BUG_ON((PAGE_SIZE >> 3) > ATOMIC_HASH_SIZE);
#endif /* ATOMIC_LOCKS_FOUND_VIA_TABLE() */
/* The futex code makes this assumption, so we validate it here. */
- BUG_ON(sizeof(atomic_t) != sizeof(int));
+ BUILD_BUG_ON(sizeof(atomic_t) != sizeof(int));
}
--
1.6.0.6
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] tile: replace some BUG_ON checks with BUILD_BUG_ON checks
2010-10-05 15:55 [PATCH] tile: replace some BUG_ON checks with BUILD_BUG_ON checks Akinobu Mita
@ 2010-10-05 16:50 ` Chris Metcalf
0 siblings, 0 replies; 2+ messages in thread
From: Chris Metcalf @ 2010-10-05 16:50 UTC (permalink / raw)
To: Akinobu Mita; +Cc: linux-kernel
On 10/5/2010 11:55 AM, Akinobu Mita wrote:
> Some BUG_ON checks can be detected at compile time rather than
> at runtime.
>
> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
> Cc: Chris Metcalf <cmetcalf@tilera.com>
> ---
>
> This patch is not compile tested.
It compiles fine.
Accepted, thanks. I also noticed another one in arch/tile/kernel/setup.c,
so I'll fix that one too.
--
Chris Metcalf, Tilera Corp.
http://www.tilera.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-10-05 16:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-05 15:55 [PATCH] tile: replace some BUG_ON checks with BUILD_BUG_ON checks Akinobu Mita
2010-10-05 16:50 ` Chris Metcalf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox