[v5,15/20] net/i40e: remove use of VLAs for Windows built code

Message ID 1731026691-1529-16-git-send-email-andremue@linux.microsoft.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series remove use of VLAs for Windows |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Andre Muezerie Nov. 8, 2024, 12:44 a.m. UTC
From: Tyler Retzlaff <roretzla@linux.microsoft.com>

MSVC does not support VLAs, replace VLAs with standard C arrays
or alloca(). alloca() is available for all toolchain/platform
combinations officially supported by DPDK.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 drivers/net/i40e/i40e_testpmd.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
  

Comments

Bruce Richardson Nov. 8, 2024, 8:45 a.m. UTC | #1
On Thu, Nov 07, 2024 at 04:44:46PM -0800, Andre Muezerie wrote:
> From: Tyler Retzlaff <roretzla@linux.microsoft.com>
> 
> MSVC does not support VLAs, replace VLAs with standard C arrays
> or alloca(). alloca() is available for all toolchain/platform
> combinations officially supported by DPDK.
> 
> Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
Reviewed-by: Bruce Richardson <bruce.richardson@intel.com>

> ---
>  drivers/net/i40e/i40e_testpmd.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/i40e/i40e_testpmd.c b/drivers/net/i40e/i40e_testpmd.c
> index b6ef5d6e42..21f596297b 100644
> --- a/drivers/net/i40e/i40e_testpmd.c
> +++ b/drivers/net/i40e/i40e_testpmd.c
> @@ -2168,8 +2168,7 @@ cmd_ptype_mapping_get_parsed(void *parsed_result,
>  {
>  	struct cmd_ptype_mapping_get_result *res = parsed_result;
>  	int ret = -ENOTSUP;
> -	int max_ptype_num = 256;
> -	struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
> +	struct rte_pmd_i40e_ptype_mapping mapping[256];
>  	uint16_t count;
>  	int i;
>  
> @@ -2178,7 +2177,7 @@ cmd_ptype_mapping_get_parsed(void *parsed_result,
>  
>  	ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
>  					mapping,
> -					max_ptype_num,
> +					RTE_DIM(mapping),
>  					&count,
>  					res->valid_only);
>  	switch (ret) {
> -- 
> 2.34.1
>
  

Patch

diff --git a/drivers/net/i40e/i40e_testpmd.c b/drivers/net/i40e/i40e_testpmd.c
index b6ef5d6e42..21f596297b 100644
--- a/drivers/net/i40e/i40e_testpmd.c
+++ b/drivers/net/i40e/i40e_testpmd.c
@@ -2168,8 +2168,7 @@  cmd_ptype_mapping_get_parsed(void *parsed_result,
 {
 	struct cmd_ptype_mapping_get_result *res = parsed_result;
 	int ret = -ENOTSUP;
-	int max_ptype_num = 256;
-	struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
+	struct rte_pmd_i40e_ptype_mapping mapping[256];
 	uint16_t count;
 	int i;
 
@@ -2178,7 +2177,7 @@  cmd_ptype_mapping_get_parsed(void *parsed_result,
 
 	ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
 					mapping,
-					max_ptype_num,
+					RTE_DIM(mapping),
 					&count,
 					res->valid_only);
 	switch (ret) {