DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] librte_pmd_null: Fix build issue with gcc-4.7
@ 2015-02-27  5:18 Tetsuya Mukawa
  2015-02-27 16:54 ` Mcnamara, John
  0 siblings, 1 reply; 3+ messages in thread
From: Tetsuya Mukawa @ 2015-02-27  5:18 UTC (permalink / raw)
  To: dev

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: Mcnamara, John <john.mcnamara@intel.com>
Reported-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
---
 lib/librte_pmd_null/rte_eth_null.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/lib/librte_pmd_null/rte_eth_null.c b/lib/librte_pmd_null/rte_eth_null.c
index bb10276..66b0d99 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] =
-- 
1.9.1

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-02-27 23:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-27  5:18 [dpdk-dev] [PATCH] librte_pmd_null: Fix build issue with gcc-4.7 Tetsuya Mukawa
2015-02-27 16:54 ` Mcnamara, John
2015-02-27 23:21   ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).