Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753662AbbGIRB3 (ORCPT ); Thu, 9 Jul 2015 13:01:29 -0400 Received: from e37.co.us.ibm.com ([32.97.110.158]:57566 "EHLO e37.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752179AbbGIRBU (ORCPT ); Thu, 9 Jul 2015 13:01:20 -0400 X-Helo: d03dlp02.boulder.ibm.com X-MailFrom: paulmck@linux.vnet.ibm.com X-RcptTo: linux-kernel@vger.kernel.org Date: Thu, 9 Jul 2015 10:01:10 -0700 From: "Paul E. McKenney" To: Alexander Gordeev Cc: linux-kernel@vger.kernel.org Subject: Re: [PATCH] rcu: Shut up bogus gcc array bounds warning Message-ID: <20150709170110.GB3717@linux.vnet.ibm.com> Reply-To: paulmck@linux.vnet.ibm.com References: <1436448863-9299-1-git-send-email-agordeev@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1436448863-9299-1-git-send-email-agordeev@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15070917-0025-0000-0000-0000151D0924 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1992 Lines: 54 On Thu, Jul 09, 2015 at 03:34:23PM +0200, Alexander Gordeev wrote: > Because gcc does not realize a loop would not be entered ever > (i.e. in case of rcu_num_lvls == 1): > > for (i = 1; i < rcu_num_lvls; i++) > rsp->level[i] = rsp->level[i - 1] + levelcnt[i - 1]; > > some compiler (pre- 5.x?) versions give a bogus warning: > > kernel/rcu/tree.c: In function ‘rcu_init_one.isra.55’: > kernel/rcu/tree.c:4108:13: warning: array subscript is above array bounds [-Warray-bounds] > rsp->level[i] = rsp->level[i - 1] + rsp->levelcnt[i - 1]; > ^ > Fix that warning by adding an extra item to rcu_state::level[] > array. Once the bogus warning is fixed in gcc and kernel drops > support of older versions, the dummy item may be removed from > the array. > > Cc: "Paul E. McKenney" > Suggested-by: "Paul E. McKenney" > Signed-off-by: Alexander Gordeev Queued, thank you! Thanx, Paul > --- > kernel/rcu/tree.h | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/kernel/rcu/tree.h b/kernel/rcu/tree.h > index 852b810..543ba72 100644 > --- a/kernel/rcu/tree.h > +++ b/kernel/rcu/tree.h > @@ -451,7 +451,9 @@ do { \ > */ > struct rcu_state { > struct rcu_node node[NUM_RCU_NODES]; /* Hierarchy. */ > - struct rcu_node *level[RCU_NUM_LVLS]; /* Hierarchy levels. */ > + struct rcu_node *level[RCU_NUM_LVLS + 1]; > + /* Hierarchy levels (+1 to */ > + /* shut bogus gcc warning) */ > u8 flavor_mask; /* bit in flavor mask. */ > struct rcu_data __percpu *rda; /* pointer of percu rcu_data. */ > void (*call)(struct rcu_head *head, /* call_rcu() flavor. */ > -- > 1.8.3.1 > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/