From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 77504C310 for ; Wed, 3 Jun 2015 15:09:33 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP; 03 Jun 2015 06:08:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,547,1427785200"; d="scan'208";a="720020697" Received: from bricha3-mobl3.ger.corp.intel.com ([10.243.20.22]) by fmsmga001.fm.intel.com with SMTP; 03 Jun 2015 06:06:48 -0700 Received: by (sSMTP sendmail emulation); Wed, 03 Jun 2015 14:06:47 +0025 Date: Wed, 3 Jun 2015 14:06:47 +0100 From: Bruce Richardson To: Thomas Monjalon Message-ID: <20150603130646.GA6236@bricha3-MOBL3> References: <1433255928-11461-1-git-send-email-thomas.monjalon@6wind.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1433255928-11461-1-git-send-email-thomas.monjalon@6wind.com> Organization: Intel Shannon Ltd. User-Agent: Mutt/1.5.23 (2014-03-12) Cc: dev@dpdk.org Subject: Re: [dpdk-dev] [PATCH] examples/load_balancer: fix build with gcc 5.1 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Jun 2015 13:09:34 -0000 On Tue, Jun 02, 2015 at 04:38:48PM +0200, Thomas Monjalon wrote: > GCC 5.1 detects more out-of-bounds accesses: > error: array subscript is above array bounds [-Werror=array-bounds] > > Signed-off-by: Thomas Monjalon > --- Acked-by: Bruce Richardson > examples/load_balancer/config.c | 16 ++++++++++++---- > 1 file changed, 12 insertions(+), 4 deletions(-) > > diff --git a/examples/load_balancer/config.c b/examples/load_balancer/config.c > index 35f1441..3f6ddee 100644 > --- a/examples/load_balancer/config.c > +++ b/examples/load_balancer/config.c > @@ -231,7 +231,9 @@ parse_arg_rx(const char *arg) > return -7; > } > lp->type = e_APP_LCORE_IO; > - for (i = 0; i < lp->io.rx.n_nic_queues; i ++) { > + const size_t n_queues = RTE_MIN(lp->io.rx.n_nic_queues, > + RTE_DIM(lp->io.rx.nic_queues)); > + for (i = 0; i < n_queues; i ++) { > if ((lp->io.rx.nic_queues[i].port == port) && > (lp->io.rx.nic_queues[i].queue == queue)) { > return -8; > @@ -308,7 +310,9 @@ parse_arg_tx(const char *arg) > return -7; > } > lp->type = e_APP_LCORE_IO; > - for (i = 0; i < lp->io.tx.n_nic_ports; i ++) { > + const size_t n_ports = RTE_MIN(lp->io.tx.n_nic_ports, > + RTE_DIM(lp->io.tx.nic_ports)); > + for (i = 0; i < n_ports; i ++) { > if (lp->io.tx.nic_ports[i] == port) { > return -8; > } > @@ -791,7 +795,9 @@ app_get_lcore_for_nic_rx(uint8_t port, uint8_t queue, uint32_t *lcore_out) > continue; > } > > - for (i = 0; i < lp->rx.n_nic_queues; i ++) { > + const size_t n_queues = RTE_MIN(lp->rx.n_nic_queues, > + RTE_DIM(lp->rx.nic_queues)); > + for (i = 0; i < n_queues; i ++) { > if ((lp->rx.nic_queues[i].port == port) && > (lp->rx.nic_queues[i].queue == queue)) { > *lcore_out = lcore; > @@ -816,7 +822,9 @@ app_get_lcore_for_nic_tx(uint8_t port, uint32_t *lcore_out) > continue; > } > > - for (i = 0; i < lp->tx.n_nic_ports; i ++) { > + const size_t n_ports = RTE_MIN(lp->tx.n_nic_ports, > + RTE_DIM(lp->tx.nic_ports)); > + for (i = 0; i < n_ports; i ++) { > if (lp->tx.nic_ports[i] == port) { > *lcore_out = lcore; > return 0; > -- > 2.4.2 >