[v12,05/21] hash: remove use of VLAs for Windows built code

Message ID 1732225298-10322-6-git-send-email-andremue@linux.microsoft.com (mailing list archive)
State Superseded
Delegated to: David Marchand
Headers
Series remove use of VLAs for Windows |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Andre Muezerie Nov. 21, 2024, 9:41 p.m. UTC
From: Konstantin Ananyev <konstantin.ananyev@huawei.com>

1) ./lib/hash/rte_cuckoo_hash.c:2362:9
    : warning: ISO C90 forbids variable length array ‘positions’
2) ../lib/hash/rte_cuckoo_hash.c:2478:9
    : warning: ISO C90 forbids variable length array ‘positions’

Both rte_hash_lookup_bulk_data() and
rte_hash_lookup_with_hash_bulk_data() expect
@num_keys <= RTE_HASH_LOOKUP_BULK_MAX.
So, for both cases it should be safe to replace VLA with fixed size
array.

Signed-off-by: Konstantin Ananyev <konstantin.ananyev@huawei.com>
Reviewed-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
---
 lib/hash/rte_cuckoo_hash.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

fengchengwen Nov. 22, 2024, 1:35 a.m. UTC | #1
Acked-by: Chengwen Feng <fengchengwen@huawei.com>

On 2024/11/22 5:41, Andre Muezerie wrote:
> From: Konstantin Ananyev <konstantin.ananyev@huawei.com>
> 
> 1) ./lib/hash/rte_cuckoo_hash.c:2362:9
>     : warning: ISO C90 forbids variable length array ‘positions’
> 2) ../lib/hash/rte_cuckoo_hash.c:2478:9
>     : warning: ISO C90 forbids variable length array ‘positions’
> 
> Both rte_hash_lookup_bulk_data() and
> rte_hash_lookup_with_hash_bulk_data() expect
> @num_keys <= RTE_HASH_LOOKUP_BULK_MAX.
> So, for both cases it should be safe to replace VLA with fixed size
> array.
> 
> Signed-off-by: Konstantin Ananyev <konstantin.ananyev@huawei.com>
> Reviewed-by: Bruce Richardson <bruce.richardson@intel.com>
> Acked-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
> ---
>  lib/hash/rte_cuckoo_hash.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
> index 9575e8aa0c..fc93182efe 100644
> --- a/lib/hash/rte_cuckoo_hash.c
> +++ b/lib/hash/rte_cuckoo_hash.c
> @@ -2418,7 +2418,7 @@ rte_hash_lookup_bulk_data(const struct rte_hash *h, const void **keys,
>  			(num_keys > RTE_HASH_LOOKUP_BULK_MAX) ||
>  			(hit_mask == NULL)), -EINVAL);
>  
> -	int32_t positions[num_keys];
> +	int32_t positions[RTE_HASH_LOOKUP_BULK_MAX];
>  
>  	__rte_hash_lookup_bulk(h, keys, num_keys, positions, hit_mask, data);
>  
> @@ -2534,7 +2534,7 @@ rte_hash_lookup_with_hash_bulk_data(const struct rte_hash *h,
>  			(num_keys > RTE_HASH_LOOKUP_BULK_MAX) ||
>  			(hit_mask == NULL)), -EINVAL);
>  
> -	int32_t positions[num_keys];
> +	int32_t positions[RTE_HASH_LOOKUP_BULK_MAX];
>  
>  	__rte_hash_lookup_with_hash_bulk(h, keys, sig, num_keys,
>  			positions, hit_mask, data);
  

Patch

diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
index 9575e8aa0c..fc93182efe 100644
--- a/lib/hash/rte_cuckoo_hash.c
+++ b/lib/hash/rte_cuckoo_hash.c
@@ -2418,7 +2418,7 @@  rte_hash_lookup_bulk_data(const struct rte_hash *h, const void **keys,
 			(num_keys > RTE_HASH_LOOKUP_BULK_MAX) ||
 			(hit_mask == NULL)), -EINVAL);
 
-	int32_t positions[num_keys];
+	int32_t positions[RTE_HASH_LOOKUP_BULK_MAX];
 
 	__rte_hash_lookup_bulk(h, keys, num_keys, positions, hit_mask, data);
 
@@ -2534,7 +2534,7 @@  rte_hash_lookup_with_hash_bulk_data(const struct rte_hash *h,
 			(num_keys > RTE_HASH_LOOKUP_BULK_MAX) ||
 			(hit_mask == NULL)), -EINVAL);
 
-	int32_t positions[num_keys];
+	int32_t positions[RTE_HASH_LOOKUP_BULK_MAX];
 
 	__rte_hash_lookup_with_hash_bulk(h, keys, sig, num_keys,
 			positions, hit_mask, data);