Consisntly use a single exit path in the code,
have the various return values set 'ret' then use the single exit path.

Signed-off-by: mstolarchuk <mike.stolarc...@bigswitch.com>
---
 lib/librte_hash/rte_cuckoo_hash.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/lib/librte_hash/rte_cuckoo_hash.c 
b/lib/librte_hash/rte_cuckoo_hash.c
index d1fbb0b..946252f 100644
--- a/lib/librte_hash/rte_cuckoo_hash.c
+++ b/lib/librte_hash/rte_cuckoo_hash.c
@@ -554,7 +554,7 @@ struct rte_hash *
                                        LCORE_CACHE_SIZE, NULL);
                        if (n_slots == 0) {
                                ret = -ENOSPC;
-                               goto failure;
+                               goto finished;
                        }
 
                        cached_free_slots->len += n_slots;
@@ -566,7 +566,7 @@ struct rte_hash *
        } else {
                if (rte_ring_sc_dequeue(h->free_slots, &slot_id) != 0) {
                        ret = -ENOSPC;
-                       goto failure;
+                       goto finished;
                }
        }
 
@@ -588,7 +588,8 @@ struct rte_hash *
                                 * Return index where key is stored,
                                 * subtracting the first dummy index
                                 */
-                               return prim_bkt->key_idx[i] - 1;
+                               ret = prim_bkt->key_idx[i] - 1;
+                               goto finished;
                        }
                }
        }
@@ -607,7 +608,8 @@ struct rte_hash *
                                 * Return index where key is stored,
                                 * subtracting the first dummy index
                                 */
-                               return sec_bkt->key_idx[i] - 1;
+                               ret = sec_bkt->key_idx[i] - 1;
+                               goto finished;
                        }
                }
        }
@@ -649,9 +651,8 @@ struct rte_hash *
                }
 
                if (i != RTE_HASH_BUCKET_ENTRIES) {
-                       if (h->add_key == ADD_KEY_MULTIWRITER)
-                               rte_spinlock_unlock(h->multiwriter_lock);
-                       return new_idx - 1;
+                       ret = new_idx - 1;
+                       goto finished;
                }
 
                /* Primary bucket full, need to make space for new entry
@@ -665,9 +666,8 @@ struct rte_hash *
                        prim_bkt->sig_current[ret] = sig;
                        prim_bkt->sig_alt[ret] = alt_hash;
                        prim_bkt->key_idx[ret] = new_idx;
-                       if (h->add_key == ADD_KEY_MULTIWRITER)
-                               rte_spinlock_unlock(h->multiwriter_lock);
-                       return new_idx - 1;
+                       ret = new_idx - 1;
+                       goto finished;
                }
 #if defined(RTE_ARCH_X86)
        }
@@ -675,7 +675,7 @@ struct rte_hash *
        /* Error in addition, store new slot back in the ring and return error 
*/
        enqueue_slot_back(h, cached_free_slots, (void *)((uintptr_t) new_idx));
 
-failure:
+finished:
        if (h->add_key == ADD_KEY_MULTIWRITER)
                rte_spinlock_unlock(h->multiwriter_lock);
        return ret;
-- 
1.9.1

Reply via email to