fix compilation on Fedora 22
cover fix compilation on Fedora 22
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(-)
Signature · 1 line
2.4.1
PATCH 1/4 eal: fix compile on Fedora 22 (GCC 5.1)
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.
--- lib/librte_eal/linuxapp/eal/eal_memory.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
lib/librte_eal/linuxapp/eal/eal_memory.c +2 -1
@@ -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
Signature · 1 line
2.4.1
Re: [PATCH 1/4] eal: fix compile on Fedora 22 (GCC 5.1)
Quoted 14 lines · Bruce Richardson
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 <[email protected]>--- lib/librte_eal/linuxapp/eal/eal_memory.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)lib/librte_eal/linuxapp/eal/eal_memory.c +0
-0
lib/librte_eal/linuxapp/eal/eal_memory.c rte_eal_hugepage_init(void) · line 1193
Quoted 7 lines
lib/librte_eal/linuxapp/eal/eal_memory.c +2
-1@@ -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
Quoted 6 lines
lib/librte_eal/linuxapp/eal/eal_memory.c +0
-0internal_config.hugepage_info[j].hugepage_sz) {#ifdef RTE_EAL_SINGLE_FILE_SEGMENTS Signature · 1 line
2.4.1
PATCH 2/4 ip_frag: fix compile on Fedora 22 (GCC 5.1)
In reply to Bruce RichardsonOn 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.
--- lib/librte_ip_frag/ip_frag_common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_ip_frag/ip_frag_common.h +1 -1
@@ -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 ;
Signature · 1 line
2.4.1
Re: [PATCH 2/4] ip_frag: fix compile on Fedora 22 (GCC 5.1)
Quoted 26 lines · Bruce Richardson
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 <[email protected]>--- lib/librte_ip_frag/ip_frag_common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/librte_ip_frag/ip_frag_common.h +1
-1@@ -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 ;Signature · 1 line
2.4.1
RTE_MIN again
Neil
PATCH 3/4 i40e: fix compile on Fedora 22 (GCC 5.1)
In reply to Bruce RichardsonOn 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.
--- drivers/net/i40e/i40e_fdir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/i40e/i40e_fdir.c +1 -1
@@ -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 =
Signature · 1 line
2.4.1
PATCH 4/4 null: fix compile on Fedora 22 (GCC 5.1)
In reply to Bruce RichardsonOn 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.
--- drivers/net/null/rte_eth_null.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/net/null/rte_eth_null.c +8 -4
@@ -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 ; }
Signature · 1 line
2.4.1
v2 cover fix compilation on Fedora 22
In reply to Bruce RichardsonV2 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(-)
Signature · 1 line
2.4.1
PATCH v2 1/4 eal: fix compile on Fedora 22 (GCC 5.1)
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.
--- lib/librte_eal/linuxapp/eal/eal_memory.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
lib/librte_eal/linuxapp/eal/eal_memory.c +3 -1
@@ -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
Signature · 1 line
2.4.1
PATCH v2 2/4 ip_frag: fix compile on Fedora 22 (GCC 5.1)
In reply to Bruce RichardsonOn 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.
--- lib/librte_ip_frag/ip_frag_common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_ip_frag/ip_frag_common.h +1 -1
@@ -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 ;
Signature · 1 line
2.4.1
PATCH v2 3/4 i40e: fix compile on Fedora 22 (GCC 5.1)
In reply to Bruce RichardsonOn 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.
--- drivers/net/i40e/i40e_fdir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/i40e/i40e_fdir.c +1 -1
@@ -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 =
Signature · 1 line
2.4.1
PATCH v2 4/4 null: fix compile on Fedora 22 (GCC 5.1)
In reply to Bruce RichardsonOn 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.
--- drivers/net/null/rte_eth_null.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/net/null/rte_eth_null.c +6 -4
@@ -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 ; }
Signature · 1 line
2.4.1
Quoted 26 lines · Bruce Richardson
V2 Changes:
* useRTE_MINinstead 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:
== Buildlib/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)
Quoted 10 lines
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(-)Signature · 1 line
2.4.1
Series
Thomas Monjalon
Applied2015-05-29 12:57, Neil Horman:
Quoted 21 lines · Bruce Richardson
Quoted 20 lines
V2 Changes:
* useRTE_MINinstead 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:
== Buildlib/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.
Quoted 8 lines
Quoted 5 lines
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 <[email protected]>
Applied, thanks