From: Bruce Richardson <bruce.richardson@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 4/4] null: fix compile on Fedora 22 (GCC 5.1)
Date: Fri, 29 May 2015 13:53:47 +0100 [thread overview]
Message-ID: <1432904027-6578-5-git-send-email-bruce.richardson@intel.com> (raw)
In-Reply-To: <1432904027-6578-1-git-send-email-bruce.richardson@intel.com>
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 counter.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
drivers/net/null/rte_eth_null.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c
index 5895065..4ca7f09 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,11 @@ 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 < internal->nb_rx_queues &&
+ 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 < internal->nb_tx_queues &&
+ 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;
}
--
2.4.1
next prev parent reply other threads:[~2015-05-29 12:53 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-29 12:53 [dpdk-dev] [PATCH 0/4] fix compilation on Fedora 22 Bruce Richardson
2015-05-29 12:53 ` [dpdk-dev] [PATCH 1/4] eal: fix compile on Fedora 22 (GCC 5.1) Bruce Richardson
2015-05-29 14:07 ` Neil Horman
2015-05-29 12:53 ` [dpdk-dev] [PATCH 2/4] ip_frag: " Bruce Richardson
2015-05-29 14:09 ` Neil Horman
2015-05-29 12:53 ` [dpdk-dev] [PATCH 3/4] i40e: " Bruce Richardson
2015-05-29 12:53 ` Bruce Richardson [this message]
2015-05-29 14:34 ` [dpdk-dev] [PATCH v2 0/4] fix compilation on Fedora 22 Bruce Richardson
2015-05-29 14:34 ` [dpdk-dev] [PATCH v2 1/4] eal: fix compile on Fedora 22 (GCC 5.1) Bruce Richardson
2015-05-29 14:34 ` [dpdk-dev] [PATCH v2 2/4] ip_frag: " Bruce Richardson
2015-05-29 14:34 ` [dpdk-dev] [PATCH v2 3/4] i40e: " Bruce Richardson
2015-05-29 14:34 ` [dpdk-dev] [PATCH v2 4/4] null: " Bruce Richardson
2015-05-29 16:57 ` [dpdk-dev] [PATCH v2 0/4] fix compilation on Fedora 22 Neil Horman
2015-06-03 14:13 ` Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1432904027-6578-5-git-send-email-bruce.richardson@intel.com \
--to=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).