Message ID | 1468583035-20118-1-git-send-email-mike.holmes@linaro.org |
---|---|
State | New |
Headers | show |
ping On 15 July 2016 at 07:43, Mike Holmes <mike.holmes@linaro.org> wrote: > fix non-void function with the possibility of no return statement > > Signed-off-by: Mike Holmes <mike.holmes@linaro.org> > --- > 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; > } > > 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) > -- > 2.7.4 > > -- Mike Holmes Technical Manager - Linaro Networking Group Linaro.org <http://www.linaro.org/> *│ *Open source software for ARM SoCs "Work should be fun and collaborative, the rest follows"
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 <mike.holmes@linaro.org> > --- > 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)
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; } 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)
fix non-void function with the possibility of no return statement Signed-off-by: Mike Holmes <mike.holmes@linaro.org> --- helper/cuckootable.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) -- 2.7.4