With --buildtype=minsize and -Werror, gcc reports that slot_id may be
used uninitialized in alloc_slot(). This is a false positive: every
path either returns EMPTY_SLOT or assigns slot_id before use.

Initialize slot_id to EMPTY_SLOT to silence the warning.

Fixes: 5915699153d7 ("hash: fix scaling by reducing contention")
Cc: [email protected]

Signed-off-by: Cheryl Bansal <[email protected]>
---
 .mailmap                   | 1 +
 lib/hash/rte_cuckoo_hash.c | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/.mailmap b/.mailmap
index a0096fb97a..5146a4fa2b 100644
--- a/.mailmap
+++ b/.mailmap
@@ -288,6 +288,7 @@ Chenna Arnoori <[email protected]>
 Chenxingyu Wang <[email protected]>
 Chenxu Di <[email protected]>
 Chenyu Huang <[email protected]>
+Cheryl Bansal <[email protected]>
 Cheryl Houser <[email protected]>
 Chinh Cao <[email protected]>
 Chintu Hetam <[email protected]>
diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
index 5d495ae973..47ea909d38 100644
--- a/lib/hash/rte_cuckoo_hash.c
+++ b/lib/hash/rte_cuckoo_hash.c
@@ -1298,7 +1298,7 @@ static inline uint32_t
 alloc_slot(const struct rte_hash *h, struct lcore_cache *cached_free_slots)
 {
        unsigned int n_slots;
-       uint32_t slot_id;
+       uint32_t slot_id = EMPTY_SLOT;
 
        if (h->use_local_cache) {
                /* Try to get a free slot from the local cache */
-- 
2.43.0

Reply via email to