diff mbox series

net/i40e: fix build with MinGW GCC 12

Message ID 20221004111742.1497105-1-thomas@monjalon.net (mailing list archive)
State Superseded, archived
Delegated to: Qi Zhang
Headers show
Series net/i40e: fix build with MinGW GCC 12 | expand

Checks

Context Check Description
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-x86_64-compile-testing fail Testing issues
ci/iol-intel-Performance fail Performance Testing issues
ci/iol-x86_64-unit-testing fail Testing issues
ci/github-robot: build success github build: passed
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/checkpatch success coding style OK

Commit Message

Thomas Monjalon Oct. 4, 2022, 11:17 a.m. UTC
When compiling with MinGW GCC 12,
the rte_flow_item array is seen as read out of bound:

net/i40e/i40e_hash.c:389:47: error:
	array subscript 50 is above array bounds of ‘const uint64_t[50]’
	{aka ‘const long long unsigned int[50]’} [-Werror=array-bounds]
	389 | item_hdr = pattern_item_header[last_item_type];
	    |            ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~

It seems the assert check done above this line has no impact.
A check is added to make the compiler happy.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 drivers/net/i40e/i40e_hash.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Thomas Monjalon Oct. 4, 2022, 11:21 a.m. UTC | #1
04/10/2022 13:17, Thomas Monjalon:
> When compiling with MinGW GCC 12,
> the rte_flow_item array is seen as read out of bound:
> 
> net/i40e/i40e_hash.c:389:47: error:
> 	array subscript 50 is above array bounds of ‘const uint64_t[50]’
> 	{aka ‘const long long unsigned int[50]’} [-Werror=array-bounds]
> 	389 | item_hdr = pattern_item_header[last_item_type];
> 	    |            ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
> 
> It seems the assert check done above this line has no impact.
> A check is added to make the compiler happy.

We could add those lines as the real issue is the item array:

Fixes: ef4c16fd9148 ("net/i40e: refactor RSS flow")
Cc: stable@dpdk.org

> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> ---
>  drivers/net/i40e/i40e_hash.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/net/i40e/i40e_hash.c b/drivers/net/i40e/i40e_hash.c
> index 8962e9d97a..ba616aea9f 100644
> --- a/drivers/net/i40e/i40e_hash.c
> +++ b/drivers/net/i40e/i40e_hash.c
> @@ -386,6 +386,8 @@ i40e_hash_get_pattern_type(const struct rte_flow_item pattern[],
>  		prev_item_type = last_item_type;
>  		assert(last_item_type < (enum rte_flow_item_type)
>  				RTE_DIM(pattern_item_header));
> +		if (last_item_type >= RTE_DIM(pattern_item_header))
> +			goto not_sup;
>  		item_hdr = pattern_item_header[last_item_type];
>  		assert(item_hdr);
>  
>
Thomas Monjalon Oct. 6, 2022, 10:27 a.m. UTC | #2
04/10/2022 13:21, Thomas Monjalon:
> 04/10/2022 13:17, Thomas Monjalon:
> > When compiling with MinGW GCC 12,
> > the rte_flow_item array is seen as read out of bound:
> > 
> > net/i40e/i40e_hash.c:389:47: error:
> > 	array subscript 50 is above array bounds of ‘const uint64_t[50]’
> > 	{aka ‘const long long unsigned int[50]’} [-Werror=array-bounds]
> > 	389 | item_hdr = pattern_item_header[last_item_type];
> > 	    |            ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
> > 
> > It seems the assert check done above this line has no impact.
> > A check is added to make the compiler happy.
> 
> We could add those lines as the real issue is the item array:
> 
> Fixes: ef4c16fd9148 ("net/i40e: refactor RSS flow")
> Cc: stable@dpdk.org
> 
> > Signed-off-by: Thomas Monjalon <thomas@monjalon.net>

A similar patch was sent 6 weeks ago by Amit Prakash Shukla.
diff mbox series

Patch

diff --git a/drivers/net/i40e/i40e_hash.c b/drivers/net/i40e/i40e_hash.c
index 8962e9d97a..ba616aea9f 100644
--- a/drivers/net/i40e/i40e_hash.c
+++ b/drivers/net/i40e/i40e_hash.c
@@ -386,6 +386,8 @@  i40e_hash_get_pattern_type(const struct rte_flow_item pattern[],
 		prev_item_type = last_item_type;
 		assert(last_item_type < (enum rte_flow_item_type)
 				RTE_DIM(pattern_item_header));
+		if (last_item_type >= RTE_DIM(pattern_item_header))
+			goto not_sup;
 		item_hdr = pattern_item_header[last_item_type];
 		assert(item_hdr);