diff options
author | Paul E. McKenney <paulmck@linux.vnet.ibm.com> | 2012-11-29 16:49:00 -0500 |
---|---|---|
committer | Paul E. McKenney <paulmck@linux.vnet.ibm.com> | 2013-01-08 17:15:25 -0500 |
commit | 4930521ae10fd28ebc713107fd243c8044a95415 (patch) | |
tree | 16b199df6f2bd65a9915ac63e29c6b0f8584097d | |
parent | 1bdc2b7d243dc8b9aadfc8002a69cf911e9e3e72 (diff) |
rcu: Silence compiler array out-of-bounds false positive
It turns out that gcc 4.8 warns on array indexes being out of bounds
unless it can prove otherwise. It gives this warning on some RCU
initialization code. Because this is far from any fastpath, add
an explicit check for array bounds and panic if so. This gives the
compiler enough information to figure out that the array index is never
out of bounds.
However, if a similar false positive occurs on a fastpath, it will
probably be necessary to tell the compiler to keep its array-index
anxieties to itself. ;-)
Markus Trippelsdorf <markus@trippelsdorf.de>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
-rw-r--r-- | kernel/rcutree.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/kernel/rcutree.c b/kernel/rcutree.c index d145796bd61f..e0d98157fbea 100644 --- a/kernel/rcutree.c +++ b/kernel/rcutree.c | |||
@@ -2938,6 +2938,10 @@ static void __init rcu_init_one(struct rcu_state *rsp, | |||
2938 | 2938 | ||
2939 | BUILD_BUG_ON(MAX_RCU_LVLS > ARRAY_SIZE(buf)); /* Fix buf[] init! */ | 2939 | BUILD_BUG_ON(MAX_RCU_LVLS > ARRAY_SIZE(buf)); /* Fix buf[] init! */ |
2940 | 2940 | ||
2941 | /* Silence gcc 4.8 warning about array index out of range. */ | ||
2942 | if (rcu_num_lvls > RCU_NUM_LVLS) | ||
2943 | panic("rcu_init_one: rcu_num_lvls overflow"); | ||
2944 | |||
2941 | /* Initialize the level-tracking arrays. */ | 2945 | /* Initialize the level-tracking arrays. */ |
2942 | 2946 | ||
2943 | for (i = 0; i < rcu_num_lvls; i++) | 2947 | for (i = 0; i < rcu_num_lvls; i++) |