DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 0/4] fix compilation on Fedora 22
@ 2015-05-29 12:53 Bruce Richardson
  2015-05-29 12:53 ` [dpdk-dev] [PATCH 1/4] eal: fix compile on Fedora 22 (GCC 5.1) Bruce Richardson
                   ` (4 more replies)
  0 siblings, 5 replies; 14+ messages in thread
From: Bruce Richardson @ 2015-05-29 12:53 UTC (permalink / raw)
  To: dev

GCC version 5.1 included with Fedora 22 is running stricter array 
bounds checks which are throwing up errors in a number of components 
in the DPDK code. This patchset fixes these errors to allow compilation
with GCC on Fedora 22.

Example error:
== Build lib/librte_eal/linuxapp/eal
  CC eal_memory.o
/home/bruce/dpdk.org/lib/librte_eal/linuxapp/eal/eal_memory.c: In function 'rte_eal_hugepage_init':
/home/bruce/dpdk.org/lib/librte_eal/linuxapp/eal/eal_memory.c:1193:35: error: array subscript is above array bounds [-Werror=array-bounds]
      internal_config.hugepage_info[j].hugepage_sz) {
                                   ^
compilation terminated due to -Wfatal-errors.


Bruce Richardson (4):
  eal: fix compile on Fedora 22 (GCC 5.1)
  ip_frag: fix compile on Fedora 22 (GCC 5.1)
  i40e: fix compile on Fedora 22 (GCC 5.1)
  null: fix compile on Fedora 22 (GCC 5.1)

 drivers/net/i40e/i40e_fdir.c             |  2 +-
 drivers/net/null/rte_eth_null.c          | 12 ++++++++----
 lib/librte_eal/linuxapp/eal/eal_memory.c |  3 ++-
 lib/librte_ip_frag/ip_frag_common.h      |  2 +-
 4 files changed, 12 insertions(+), 7 deletions(-)

-- 
2.4.1

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

* [dpdk-dev] [PATCH 1/4] eal: fix compile on Fedora 22 (GCC 5.1)
  2015-05-29 12:53 [dpdk-dev] [PATCH 0/4] fix compilation on Fedora 22 Bruce Richardson
@ 2015-05-29 12:53 ` Bruce Richardson
  2015-05-29 14:07   ` Neil Horman
  2015-05-29 12:53 ` [dpdk-dev] [PATCH 2/4] ip_frag: " Bruce Richardson
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 14+ messages in thread
From: Bruce Richardson @ 2015-05-29 12:53 UTC (permalink / raw)
  To: dev

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>
---
 lib/librte_eal/linuxapp/eal/eal_memory.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c
index 5f9f92e..744635f 100644
--- a/lib/librte_eal/linuxapp/eal/eal_memory.c
+++ b/lib/librte_eal/linuxapp/eal/eal_memory.c
@@ -1188,7 +1188,8 @@ rte_eal_hugepage_init(void)
 		int socket = tmp_hp[i].socket_id;
 
 		/* find a hugepage info with right size and increment num_pages */
-		for (j = 0; j < (int) internal_config.num_hugepage_sizes; j++) {
+		for (j = 0; j < (int) internal_config.num_hugepage_sizes &&
+				j < MAX_HUGEPAGE_SIZES; j++) {
 			if (tmp_hp[i].size ==
 					internal_config.hugepage_info[j].hugepage_sz) {
 #ifdef RTE_EAL_SINGLE_FILE_SEGMENTS
-- 
2.4.1

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

* [dpdk-dev] [PATCH 2/4] ip_frag: fix compile on Fedora 22 (GCC 5.1)
  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 12:53 ` Bruce Richardson
  2015-05-29 14:09   ` Neil Horman
  2015-05-29 12:53 ` [dpdk-dev] [PATCH 3/4] i40e: " Bruce Richardson
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 14+ messages in thread
From: Bruce Richardson @ 2015-05-29 12:53 UTC (permalink / raw)
  To: dev

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>
---
 lib/librte_ip_frag/ip_frag_common.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_ip_frag/ip_frag_common.h b/lib/librte_ip_frag/ip_frag_common.h
index 210f409..e37073b 100644
--- a/lib/librte_ip_frag/ip_frag_common.h
+++ b/lib/librte_ip_frag/ip_frag_common.h
@@ -90,7 +90,7 @@ static inline int
 ip_frag_key_is_empty(const struct ip_frag_key * key)
 {
 	uint32_t i;
-	for (i = 0; i < key->key_len; i++)
+	for (i = 0; i < key->key_len && i < RTE_DIM(key->src_dst); i++)
 		if (key->src_dst[i] != 0)
 			return 0;
 	return 1;
-- 
2.4.1

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

* [dpdk-dev] [PATCH 3/4] i40e: fix compile on Fedora 22 (GCC 5.1)
  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 12:53 ` [dpdk-dev] [PATCH 2/4] ip_frag: " Bruce Richardson
@ 2015-05-29 12:53 ` Bruce Richardson
  2015-05-29 12:53 ` [dpdk-dev] [PATCH 4/4] null: " Bruce Richardson
  2015-05-29 14:34 ` [dpdk-dev] [PATCH v2 0/4] fix compilation on Fedora 22 Bruce Richardson
  4 siblings, 0 replies; 14+ messages in thread
From: Bruce Richardson @ 2015-05-29 12:53 UTC (permalink / raw)
  To: dev

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/i40e/i40e_fdir.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/i40e/i40e_fdir.c b/drivers/net/i40e/i40e_fdir.c
index e688b4f..55cf2cf 100644
--- a/drivers/net/i40e/i40e_fdir.c
+++ b/drivers/net/i40e/i40e_fdir.c
@@ -551,7 +551,7 @@ i40e_set_flx_pld_cfg(struct i40e_pf *pf,
 	memset(flex_pit, 0, sizeof(flex_pit));
 	num = i40e_srcoff_to_flx_pit(cfg->src_offset, flex_pit);
 
-	for (i = 0; i < num; i++) {
+	for (i = 0; i < num && i < RTE_DIM(flex_pit); i++) {
 		field_idx = layer_idx * I40E_MAX_FLXPLD_FIED + i;
 		/* record the info in fdir structure */
 		pf->fdir.flex_set[field_idx].src_offset =
-- 
2.4.1

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

* [dpdk-dev] [PATCH 4/4] null: fix compile on Fedora 22 (GCC 5.1)
  2015-05-29 12:53 [dpdk-dev] [PATCH 0/4] fix compilation on Fedora 22 Bruce Richardson
                   ` (2 preceding siblings ...)
  2015-05-29 12:53 ` [dpdk-dev] [PATCH 3/4] i40e: " Bruce Richardson
@ 2015-05-29 12:53 ` Bruce Richardson
  2015-05-29 14:34 ` [dpdk-dev] [PATCH v2 0/4] fix compilation on Fedora 22 Bruce Richardson
  4 siblings, 0 replies; 14+ messages in thread
From: Bruce Richardson @ 2015-05-29 12:53 UTC (permalink / raw)
  To: dev

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

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

* Re: [dpdk-dev] [PATCH 1/4] eal: fix compile on Fedora 22 (GCC 5.1)
  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
  0 siblings, 0 replies; 14+ messages in thread
From: Neil Horman @ 2015-05-29 14:07 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev

On Fri, May 29, 2015 at 01:53:44PM +0100, Bruce Richardson wrote:
> 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>
> ---
>  lib/librte_eal/linuxapp/eal/eal_memory.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c
> index 5f9f92e..744635f 100644
> --- a/lib/librte_eal/linuxapp/eal/eal_memory.c
> +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c
> @@ -1188,7 +1188,8 @@ rte_eal_hugepage_init(void)
>  		int socket = tmp_hp[i].socket_id;
>  
>  		/* find a hugepage info with right size and increment num_pages */
> -		for (j = 0; j < (int) internal_config.num_hugepage_sizes; j++) {
> +		for (j = 0; j < (int) internal_config.num_hugepage_sizes &&
> +				j < MAX_HUGEPAGE_SIZES; j++) {
>  			if (tmp_hp[i].size ==
Use RTE_MIN here, it will look alot cleaner I think
Neil

>  					internal_config.hugepage_info[j].hugepage_sz) {
>  #ifdef RTE_EAL_SINGLE_FILE_SEGMENTS
> -- 
> 2.4.1
> 
> 

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

* Re: [dpdk-dev] [PATCH 2/4] ip_frag: fix compile on Fedora 22 (GCC 5.1)
  2015-05-29 12:53 ` [dpdk-dev] [PATCH 2/4] ip_frag: " Bruce Richardson
@ 2015-05-29 14:09   ` Neil Horman
  0 siblings, 0 replies; 14+ messages in thread
From: Neil Horman @ 2015-05-29 14:09 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev

On Fri, May 29, 2015 at 01:53:45PM +0100, Bruce Richardson wrote:
> 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>
> ---
>  lib/librte_ip_frag/ip_frag_common.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/librte_ip_frag/ip_frag_common.h b/lib/librte_ip_frag/ip_frag_common.h
> index 210f409..e37073b 100644
> --- a/lib/librte_ip_frag/ip_frag_common.h
> +++ b/lib/librte_ip_frag/ip_frag_common.h
> @@ -90,7 +90,7 @@ static inline int
>  ip_frag_key_is_empty(const struct ip_frag_key * key)
>  {
>  	uint32_t i;
> -	for (i = 0; i < key->key_len; i++)
> +	for (i = 0; i < key->key_len && i < RTE_DIM(key->src_dst); i++)
>  		if (key->src_dst[i] != 0)
>  			return 0;
>  	return 1;
> -- 
> 2.4.1
> 
> 
RTE_MIN again
Neil

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

* [dpdk-dev] [PATCH v2 0/4] fix compilation on Fedora 22
  2015-05-29 12:53 [dpdk-dev] [PATCH 0/4] fix compilation on Fedora 22 Bruce Richardson
                   ` (3 preceding siblings ...)
  2015-05-29 12:53 ` [dpdk-dev] [PATCH 4/4] null: " Bruce Richardson
@ 2015-05-29 14:34 ` Bruce Richardson
  2015-05-29 14:34   ` [dpdk-dev] [PATCH v2 1/4] eal: fix compile on Fedora 22 (GCC 5.1) Bruce Richardson
                     ` (4 more replies)
  4 siblings, 5 replies; 14+ messages in thread
From: Bruce Richardson @ 2015-05-29 14:34 UTC (permalink / raw)
  To: dev; +Cc: neil.horman

V2 Changes: 
* use RTE_MIN instead of additional comparison checks
  in some loops, as suggested by Neil.
* For stats reset in null PMD, just use the size of the
  array [which is 1] in place of the used queue counts.

GCC version 5.1 included with Fedora 22 is running stricter array 
bounds checks which are throwing up errors in a number of components 
in the DPDK code. This patchset fixes these errors to allow compilation
with GCC on Fedora 22.

Example error:
== Build lib/librte_eal/linuxapp/eal
  CC eal_memory.o
/home/bruce/dpdk.org/lib/librte_eal/linuxapp/eal/eal_memory.c: In function 'rte_eal_hugepage_init':
/home/bruce/dpdk.org/lib/librte_eal/linuxapp/eal/eal_memory.c:1193:35: error: array subscript is above array bounds [-Werror=array-bounds]
      internal_config.hugepage_info[j].hugepage_sz) {
                                   ^
compilation terminated due to -Wfatal-errors.

Bruce Richardson (4):
  eal: fix compile on Fedora 22 (GCC 5.1)
  ip_frag: fix compile on Fedora 22 (GCC 5.1)
  i40e: fix compile on Fedora 22 (GCC 5.1)
  null: fix compile on Fedora 22 (GCC 5.1)

 drivers/net/i40e/i40e_fdir.c             |  2 +-
 drivers/net/null/rte_eth_null.c          | 12 ++++++++----
 lib/librte_eal/linuxapp/eal/eal_memory.c |  4 +++-
 lib/librte_ip_frag/ip_frag_common.h      |  2 +-
 4 files changed, 13 insertions(+), 7 deletions(-)

-- 
2.4.1

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

* [dpdk-dev] [PATCH v2 1/4] eal: fix compile on Fedora 22 (GCC 5.1)
  2015-05-29 14:34 ` [dpdk-dev] [PATCH v2 0/4] fix compilation on Fedora 22 Bruce Richardson
@ 2015-05-29 14:34   ` Bruce Richardson
  2015-05-29 14:34   ` [dpdk-dev] [PATCH v2 2/4] ip_frag: " Bruce Richardson
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 14+ messages in thread
From: Bruce Richardson @ 2015-05-29 14:34 UTC (permalink / raw)
  To: dev; +Cc: neil.horman

On Fedora 22, with GCC 5.1, errors are reported due to array accesses
being potentially out of bounds. This commit fixes this by ensuring the
bounds check in the loop takes account of the array size.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 lib/librte_eal/linuxapp/eal/eal_memory.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c
index 5f9f92e..9b8d946 100644
--- a/lib/librte_eal/linuxapp/eal/eal_memory.c
+++ b/lib/librte_eal/linuxapp/eal/eal_memory.c
@@ -1188,7 +1188,9 @@ rte_eal_hugepage_init(void)
 		int socket = tmp_hp[i].socket_id;
 
 		/* find a hugepage info with right size and increment num_pages */
-		for (j = 0; j < (int) internal_config.num_hugepage_sizes; j++) {
+		const int nb_hpsizes = RTE_MIN(MAX_HUGEPAGE_SIZES,
+				(int)internal_config.num_hugepage_sizes);
+		for (j = 0; j < nb_hpsizes; j++) {
 			if (tmp_hp[i].size ==
 					internal_config.hugepage_info[j].hugepage_sz) {
 #ifdef RTE_EAL_SINGLE_FILE_SEGMENTS
-- 
2.4.1

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

* [dpdk-dev] [PATCH v2 2/4] ip_frag: fix compile on Fedora 22 (GCC 5.1)
  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   ` Bruce Richardson
  2015-05-29 14:34   ` [dpdk-dev] [PATCH v2 3/4] i40e: " Bruce Richardson
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 14+ messages in thread
From: Bruce Richardson @ 2015-05-29 14:34 UTC (permalink / raw)
  To: dev; +Cc: neil.horman

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>
---
 lib/librte_ip_frag/ip_frag_common.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_ip_frag/ip_frag_common.h b/lib/librte_ip_frag/ip_frag_common.h
index 210f409..6b2acee 100644
--- a/lib/librte_ip_frag/ip_frag_common.h
+++ b/lib/librte_ip_frag/ip_frag_common.h
@@ -90,7 +90,7 @@ static inline int
 ip_frag_key_is_empty(const struct ip_frag_key * key)
 {
 	uint32_t i;
-	for (i = 0; i < key->key_len; i++)
+	for (i = 0; i < RTE_MIN(key->key_len, RTE_DIM(key->src_dst)); i++)
 		if (key->src_dst[i] != 0)
 			return 0;
 	return 1;
-- 
2.4.1

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

* [dpdk-dev] [PATCH v2 3/4] i40e: fix compile on Fedora 22 (GCC 5.1)
  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   ` 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
  4 siblings, 0 replies; 14+ messages in thread
From: Bruce Richardson @ 2015-05-29 14:34 UTC (permalink / raw)
  To: dev; +Cc: neil.horman

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/i40e/i40e_fdir.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/i40e/i40e_fdir.c b/drivers/net/i40e/i40e_fdir.c
index e688b4f..4bf98d0 100644
--- a/drivers/net/i40e/i40e_fdir.c
+++ b/drivers/net/i40e/i40e_fdir.c
@@ -551,7 +551,7 @@ i40e_set_flx_pld_cfg(struct i40e_pf *pf,
 	memset(flex_pit, 0, sizeof(flex_pit));
 	num = i40e_srcoff_to_flx_pit(cfg->src_offset, flex_pit);
 
-	for (i = 0; i < num; i++) {
+	for (i = 0; i < RTE_MIN(num, RTE_DIM(flex_pit)); i++) {
 		field_idx = layer_idx * I40E_MAX_FLXPLD_FIED + i;
 		/* record the info in fdir structure */
 		pf->fdir.flex_set[field_idx].src_offset =
-- 
2.4.1

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

* [dpdk-dev] [PATCH v2 4/4] null: fix compile on Fedora 22 (GCC 5.1)
  2015-05-29 14:34 ` [dpdk-dev] [PATCH v2 0/4] fix compilation on Fedora 22 Bruce Richardson
                     ` (2 preceding siblings ...)
  2015-05-29 14:34   ` [dpdk-dev] [PATCH v2 3/4] i40e: " Bruce Richardson
@ 2015-05-29 14:34   ` Bruce Richardson
  2015-05-29 16:57   ` [dpdk-dev] [PATCH v2 0/4] fix compilation on Fedora 22 Neil Horman
  4 siblings, 0 replies; 14+ messages in thread
From: Bruce Richardson @ 2015-05-29 14:34 UTC (permalink / raw)
  To: dev; +Cc: neil.horman

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>
---
 drivers/net/null/rte_eth_null.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c
index 5895065..7792315 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;
 	}
-- 
2.4.1

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

* Re: [dpdk-dev] [PATCH v2 0/4] fix compilation on Fedora 22
  2015-05-29 14:34 ` [dpdk-dev] [PATCH v2 0/4] fix compilation on Fedora 22 Bruce Richardson
                     ` (3 preceding siblings ...)
  2015-05-29 14:34   ` [dpdk-dev] [PATCH v2 4/4] null: " Bruce Richardson
@ 2015-05-29 16:57   ` Neil Horman
  2015-06-03 14:13     ` Thomas Monjalon
  4 siblings, 1 reply; 14+ messages in thread
From: Neil Horman @ 2015-05-29 16:57 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev, neil.horman

On Fri, May 29, 2015 at 03:34:12PM +0100, Bruce Richardson wrote:
> V2 Changes: 
> * use RTE_MIN instead of additional comparison checks
>   in some loops, as suggested by Neil.
> * For stats reset in null PMD, just use the size of the
>   array [which is 1] in place of the used queue counts.
> 
> GCC version 5.1 included with Fedora 22 is running stricter array 
> bounds checks which are throwing up errors in a number of components 
> in the DPDK code. This patchset fixes these errors to allow compilation
> with GCC on Fedora 22.
> 
> Example error:
> == Build lib/librte_eal/linuxapp/eal
>   CC eal_memory.o
> /home/bruce/dpdk.org/lib/librte_eal/linuxapp/eal/eal_memory.c: In function 'rte_eal_hugepage_init':
> /home/bruce/dpdk.org/lib/librte_eal/linuxapp/eal/eal_memory.c:1193:35: error: array subscript is above array bounds [-Werror=array-bounds]
>       internal_config.hugepage_info[j].hugepage_sz) {
>                                    ^
> compilation terminated due to -Wfatal-errors.
> 
> Bruce Richardson (4):
>   eal: fix compile on Fedora 22 (GCC 5.1)
>   ip_frag: fix compile on Fedora 22 (GCC 5.1)
>   i40e: fix compile on Fedora 22 (GCC 5.1)
>   null: fix compile on Fedora 22 (GCC 5.1)
> 
>  drivers/net/i40e/i40e_fdir.c             |  2 +-
>  drivers/net/null/rte_eth_null.c          | 12 ++++++++----
>  lib/librte_eal/linuxapp/eal/eal_memory.c |  4 +++-
>  lib/librte_ip_frag/ip_frag_common.h      |  2 +-
>  4 files changed, 13 insertions(+), 7 deletions(-)
> 
> -- 
> 2.4.1
> 
> 

Series
Acked-by: Neil Horman <nhorman@tuxdriver.com>

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

* Re: [dpdk-dev] [PATCH v2 0/4] fix compilation on Fedora 22
  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
  0 siblings, 0 replies; 14+ messages in thread
From: Thomas Monjalon @ 2015-06-03 14:13 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev, neil.horman

2015-05-29 12:57, Neil Horman:
> On Fri, May 29, 2015 at 03:34:12PM +0100, Bruce Richardson wrote:
> > V2 Changes: 
> > * use RTE_MIN instead of additional comparison checks
> >   in some loops, as suggested by Neil.
> > * For stats reset in null PMD, just use the size of the
> >   array [which is 1] in place of the used queue counts.
> > 
> > GCC version 5.1 included with Fedora 22 is running stricter array 
> > bounds checks which are throwing up errors in a number of components 
> > in the DPDK code. This patchset fixes these errors to allow compilation
> > with GCC on Fedora 22.
> > 
> > Example error:
> > == Build lib/librte_eal/linuxapp/eal
> >   CC eal_memory.o
> > /home/bruce/dpdk.org/lib/librte_eal/linuxapp/eal/eal_memory.c: In function 'rte_eal_hugepage_init':
> > /home/bruce/dpdk.org/lib/librte_eal/linuxapp/eal/eal_memory.c:1193:35: error: array subscript is above array bounds [-Werror=array-bounds]
> >       internal_config.hugepage_info[j].hugepage_sz) {
> >                                    ^
> > compilation terminated due to -Wfatal-errors.
> > 
> > Bruce Richardson (4):
> >   eal: fix compile on Fedora 22 (GCC 5.1)
> >   ip_frag: fix compile on Fedora 22 (GCC 5.1)
> >   i40e: fix compile on Fedora 22 (GCC 5.1)
> >   null: fix compile on Fedora 22 (GCC 5.1)
> 
> Series
> Acked-by: Neil Horman <nhorman@tuxdriver.com>

Applied, thanks

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

end of thread, other threads:[~2015-06-03 14:14 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [dpdk-dev] [PATCH 4/4] null: " Bruce Richardson
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

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).