@@ -87,8 +87,8 @@ static timeout_t *rem_tmo(tick_t *tick)
/**
* Search and delete tmo entry from timeout list
- * return 0 : on error.. handle not in list
- * 1 : success
+ * return -1 : on error.. handle not in list
+ * 0 : success
*/
static int find_and_del_tmo(timeout_t **tmo, odp_timer_tmo_t handle)
{
@@ -106,13 +106,12 @@ static int find_and_del_tmo(timeout_t **tmo, odp_timer_tmo_t handle)
}
}
- if (!cur) {
- ODP_ERR("Couldn't find the tmo handle (%d)\n", handle);
- return 0;
- }
+ if (!cur)
+ /* couldn't find tmo in list */
+ return -1;
/* application to free tmo_buf provided by absolute_tmo call */
- return 1;
+ return 0;
}
int odp_timer_cancel_tmo(odp_timer_t timer, odp_timer_tmo_t tmo)
@@ -132,9 +131,9 @@ int odp_timer_cancel_tmo(odp_timer_t timer, odp_timer_tmo_t tmo)
odp_spinlock_lock(&tick->lock);
/* search and delete tmo from tick list */
- if (find_and_del_tmo(&tick->list, tmo) == 0) {
- ODP_ERR("cancel failed for tim id %d tmo id :%d tick idx %lu\n", id, tmo, tick_idx);
+ if (find_and_del_tmo(&tick->list, tmo) != 0) {
odp_spinlock_unlock(&tick->lock);
+ ODP_DBG("Couldn't find the tmo (%d) in tick list\n", tmo);
return -1;
}
odp_spinlock_unlock(&tick->lock);
@@ -254,7 +254,7 @@ static int ping_init(int count, char *name[])
bzero(&dst_addr, sizeof(dst_addr));
dst_addr.sin_family = hname->h_addrtype;
dst_addr.sin_port = 0;
- dst_addr.sin_addr.s_addr = *(long *)hname->h_addr;
+ dst_addr.sin_addr.s_addr = *(long *)(void *)hname->h_addr;
}
printf("ping to addr %s\n", name[1]);
source/odp_timer.c: In function ‘odp_timer_cancel_tmo’:wq! source/odp_timer.c:136:3: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 8 has type ‘uint64_t’ [-Werror=format=] ODP_ERR("cancel failed for tim id %d tmo id :%d tick idx %lu\n", id, tmo, tick_idx); odp_timer_ping.c: In function ‘ping_init’: odp_timer_ping.c:257:31: error: cast increases required alignment of target type [-Werror=cast-align] dst_addr.sin_addr.s_addr = *(long *)hname->h_addr; - Move ODP_ERR outside spinlock - Replace ODP_ERR with ODP_DBG, as search_and_delete_tmo() func may fail for valid case like entry in list already deleted by timeout handler which is a valid case but then odp_err messaging is wrong..(pointed out by Ola). The invalid case still fall into same loop and may confuse for now, thus need to identify possible erronoing so to decode error message. I am leaving this open for now (possible errorno in timer implementation) ..will evolve in phases (TODO) Signed-off-by: santosh shukla <santosh.shukla@linaro.org> --- v2 : - Move ODP_ERR outside spinlock - Replace ODP_ERR with ODP_DBG, as search_and_delete_tmo() func may fail for valid case like entry in list already deleted by timeout handler which is a valid case but then odp_err messaging is wrong..(pointed out by Ola). The invalid case still fall into same loop and may confuse for now, thus need to identify possible erronoing so to decode error message. I am leaving this open for now (possible errorno in timer implementation) ..will evolve in phases (TODO) platform/linux-generic/source/odp_timer.c | 17 ++++++++--------- test/api_test/odp_timer_ping.c | 2 +- 2 files changed, 9 insertions(+), 10 deletions(-)