From: Bruce Richardson Date: Fri, 29 May 2015 14:34:16 +0000 (+0100) Subject: null: fix build with gcc 5.1 X-Git-Tag: spdx-start~9144 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=b34141b284f07eff7e04ed7dd0302b2e4dc3c7d9;p=dpdk.git null: fix build with gcc 5.1 On Fedora 22, with GCC 5.1, errors are reported due to array accesses being potentially out of bounds. This commit fixes this by adding in an extra bounds check to the loop counters, or, in the case of stats reset, by blindly zeroing the whole array, rather than just the part that is in use. Signed-off-by: Bruce Richardson Acked-by: Neil Horman --- diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c index 58950659a7..7792315c01 100644 --- a/drivers/net/null/rte_eth_null.c +++ b/drivers/net/null/rte_eth_null.c @@ -298,7 +298,8 @@ eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *igb_stats) internal = dev->data->dev_private; memset(igb_stats, 0, sizeof(*igb_stats)); num_stats = RTE_MIN((unsigned)RTE_ETHDEV_QUEUE_STAT_CNTRS, - internal->nb_rx_queues); + RTE_MIN(internal->nb_rx_queues, + RTE_DIM(internal->rx_null_queues))); for (i = 0; i < num_stats; i++) { igb_stats->q_ipackets[i] = internal->rx_null_queues[i].rx_pkts.cnt; @@ -306,7 +307,8 @@ eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *igb_stats) } num_stats = RTE_MIN((unsigned)RTE_ETHDEV_QUEUE_STAT_CNTRS, - internal->nb_tx_queues); + RTE_MIN(internal->nb_tx_queues, + RTE_DIM(internal->tx_null_queues))); for (i = 0; i < num_stats; i++) { igb_stats->q_opackets[i] = internal->tx_null_queues[i].tx_pkts.cnt; @@ -331,9 +333,9 @@ eth_stats_reset(struct rte_eth_dev *dev) return; internal = dev->data->dev_private; - for (i = 0; i < internal->nb_rx_queues; i++) + for (i = 0; i < RTE_DIM(internal->rx_null_queues); i++) internal->rx_null_queues[i].rx_pkts.cnt = 0; - for (i = 0; i < internal->nb_tx_queues; i++) { + for (i = 0; i < RTE_DIM(internal->tx_null_queues); i++) { internal->tx_null_queues[i].tx_pkts.cnt = 0; internal->tx_null_queues[i].err_pkts.cnt = 0; }