On 07/15/16 14:43, Mike Holmes wrote:
fix non-void function with the possibility of no return statement

Signed-off-by: Mike Holmes <[email protected]>
---
  helper/cuckootable.c | 10 +++++++---
  1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/helper/cuckootable.c b/helper/cuckootable.c
index 91a73b4..1327a40 100644
--- a/helper/cuckootable.c
+++ b/helper/cuckootable.c
@@ -171,10 +171,12 @@ odph_cuckoo_table_lookup(const char *name)
        tbl = (odph_cuckoo_table_impl *)odp_shm_addr(odp_shm_lookup(name));
if (
-               tbl != NULL &&
+               !(tbl != NULL &&
                tbl->magicword == ODPH_CUCKOO_TABLE_MAGIC_WORD &&
-               strcmp(tbl->name, name) == 0)
-               return (odph_table_t)tbl;
+               strcmp(tbl->name, name) == 0))
+               tbl = NULL;
+
+       return (odph_table_t)tbl;
  }

I think it make sense to simplify above checks:

        tbl = (odph_cuckoo_table_impl *)odp_shm_addr(odp_shm_lookup(name));
has to be:
odp_shm_t shm = odp_shm_lookup(name)
if (shm == ODP_SHM_INVALID)
    return NULL;

tbl = odp_shm_addr(shm);


then simple:

    if (tbl->magicword == ODPH_CUCKOO_TABLE_MAGIC_WORD &&
                strcmp(tbl->name, name) == 0)
        return tbl;
    else
        return NULL;

btw, there is no reason to set tbl to NULL at the initialization.

Maxim.






odph_table_t
@@ -355,6 +357,8 @@ odph_cuckoo_table_destroy(odph_table_t tbl)
/* free impl */
        odp_shm_free(odp_shm_lookup(impl->name));
+
+       return 0;
  }
static uint32_t hash(const odph_cuckoo_table_impl *h, const void *key)

Reply via email to