[RFC 4/6] hash: remove VLA warnings
Konstantin Ananyev
konstantin.v.ananyev at yandex.ru
Thu Apr 18 12:33:12 CEST 2024
From: Konstantin Ananyev <konstantin.ananyev at huawei.com>
1) ./lib/hash/rte_cuckoo_hash.c:2362:9: warning: ISO C90 forbids variable length array ‘positions’ [-Wvla]
2) ../lib/hash/rte_cuckoo_hash.c:2478:9: warning: ISO C90 forbids variable length array ‘positions’ [-Wvla]
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 at huawei.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 9cf94645f6..82b74bda18 100644
--- a/lib/hash/rte_cuckoo_hash.c
+++ b/lib/hash/rte_cuckoo_hash.c
@@ -2359,7 +2359,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);
@@ -2475,7 +2475,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);
--
2.35.3
More information about the dev
mailing list