From 2219c32784071b6c37ea57185382e3228ed4b0a7 Mon Sep 17 00:00:00 2001 From: wangchen <253227059@qq.com> Date: Mon, 17 Jan 2022 03:25:50 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20L0=20pthread=5Fcond=5Ftimedwait=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=AE=9E=E7=8E=B0=E5=AD=98=E5=9C=A8=E7=9A=84=E5=87=A0?= =?UTF-8?q?=E4=B8=AA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【背景】L0 pthread_cond_timedwait接口存在计算溢出 【修改方案】 1,新增abstick 相关修改,先判断再转成32位,避免截断 2,LOS_Event相关函数返回值的处理已存在,无需处理 【影响】 对现有的产品编译不会有影响。 re #I4N9P8 Signed-off-by: wangchen --- kal/posix/src/pthread_cond.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kal/posix/src/pthread_cond.c b/kal/posix/src/pthread_cond.c index e7d62e61..9e2ca660 100644 --- a/kal/posix/src/pthread_cond.c +++ b/kal/posix/src/pthread_cond.c @@ -229,7 +229,7 @@ int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec *ts) { INT32 ret; - UINT32 absTicks; + UINT64 absTicks; const UINT32 nsPerTick = OS_SYS_NS_PER_SECOND / LOSCFG_BASE_CORE_TICK_PER_SECOND; struct timespec tp; UINT64 nseconds; @@ -269,7 +269,8 @@ int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, PRINT_ERR("%s: %d failed\n", __FUNCTION__, __LINE__); } - ret = (INT32)LOS_EventRead(&(cond->event), 0x0f, LOS_WAITMODE_OR | LOS_WAITMODE_CLR, absTicks); + (VOID)LOS_EventClear(&(cond->event), 0); + ret = (INT32)LOS_EventRead(&(cond->event), 0x0f, LOS_WAITMODE_OR | LOS_WAITMODE_CLR, (UINT32)absTicks); if (pthread_mutex_lock(mutex) != 0) { PRINT_ERR("%s: %d failed\n", __FUNCTION__, __LINE__);