]> git.droids-corp.org - dpdk.git/commitdiff
null: fix build with gcc 5.1
authorBruce Richardson <bruce.richardson@intel.com>
Fri, 29 May 2015 14:34:16 +0000 (15:34 +0100)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Tue, 2 Jun 2015 16:24:28 +0000 (18:24 +0200)
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 <bruce.richardson@intel.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
drivers/net/null/rte_eth_null.c

index 58950659a78d84e5f8c9f037713b1b7438e9097a..7792315c01f77b14b67cd0600aba04edac84852d 100644 (file)
@@ -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;
        }