From: Tetsuya Mukawa Date: Fri, 27 Feb 2015 05:18:18 +0000 (+0900) Subject: null: fix build with gcc-4.7 X-Git-Tag: spdx-start~9516 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=e34550c8b97826e23c5d0614ef0ce8ab7093c903;p=dpdk.git null: fix build with gcc-4.7 This patch fixes following errors with gcc-4.7. lib/librte_pmd_null/rte_eth_null.c:302:28: error: array subscript is above array bounds Reported-by: John McNamara Reported-by: Stephen Hemminger Signed-off-by: Tetsuya Mukawa Acked-by: John McNamara --- diff --git a/lib/librte_pmd_null/rte_eth_null.c b/lib/librte_pmd_null/rte_eth_null.c index 3ef58424e8..f49d6864ae 100644 --- a/lib/librte_pmd_null/rte_eth_null.c +++ b/lib/librte_pmd_null/rte_eth_null.c @@ -287,7 +287,7 @@ eth_dev_info(struct rte_eth_dev *dev, static void eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *igb_stats) { - unsigned i; + unsigned i, num_stats; unsigned long rx_total = 0, tx_total = 0, tx_err_total = 0; const struct pmd_internals *internal; @@ -296,15 +296,17 @@ 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)); - for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS && - i < internal->nb_rx_queues; i++) { + num_stats = RTE_MIN((unsigned)RTE_ETHDEV_QUEUE_STAT_CNTRS, + internal->nb_rx_queues); + for (i = 0; i < num_stats; i++) { igb_stats->q_ipackets[i] = internal->rx_null_queues[i].rx_pkts.cnt; rx_total += igb_stats->q_ipackets[i]; } - for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS && - i < internal->nb_tx_queues; i++) { + num_stats = RTE_MIN((unsigned)RTE_ETHDEV_QUEUE_STAT_CNTRS, + internal->nb_tx_queues); + for (i = 0; i < num_stats; i++) { igb_stats->q_opackets[i] = internal->tx_null_queues[i].tx_pkts.cnt; igb_stats->q_errors[i] =