From bdd6811230be40bcaa5bd4a5ec1338b16dc6e18f Mon Sep 17 00:00:00 2001 From: zhkag Date: Thu, 2 Feb 2023 11:16:38 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E6=97=A0=E7=94=A8=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/libc/compilers/common/ctime.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/components/libc/compilers/common/ctime.c b/components/libc/compilers/common/ctime.c index dc6e3dd538..0fa3449a35 100644 --- a/components/libc/compilers/common/ctime.c +++ b/components/libc/compilers/common/ctime.c @@ -954,8 +954,8 @@ struct timer_obj *timer_id_get(int timerid) timer_id_lock(); if (_g_timerid[timerid] == NULL) { - LOG_E("can not find timer!"); timer_id_unlock(); + LOG_E("can not find timer!"); return NULL; } timer = _g_timerid[timerid]; @@ -1035,14 +1035,13 @@ int timer_create(clockid_t clockid, struct sigevent *evp, timer_t *timerid) _timerid = timer_id_alloc(); if (_timerid < 0) { + timer_id_unlock(); LOG_E("_timerid overflow!"); return -1; /* todo:memory leak */ } _g_timerid[_timerid] = timer; *timerid = _timerid; timer_id_unlock(); - rt_kprintf("_timerid %d\r\n", _timerid); - // *timerid = (timer_t)((uintptr_t)timer >> 1); return 0; } @@ -1055,14 +1054,13 @@ RTM_EXPORT(timer_create); */ int timer_delete(timer_t timerid) { - // struct timer_obj *timer = (struct timer_obj *)((uintptr_t)timerid << 1); struct timer_obj *timer; timer_id_lock(); if (_g_timerid[(int)timerid] == NULL) { - LOG_E("can not find timer!"); - rt_set_errno(EINVAL); timer_id_unlock(); + rt_set_errno(EINVAL); + LOG_E("can not find timer!"); return -1; } timer = _g_timerid[(int)timerid]; @@ -1105,7 +1103,6 @@ int timer_getoverrun(timer_t timerid) */ int timer_gettime(timer_t timerid, struct itimerspec *its) { - // struct timer_obj *timer = (struct timer_obj *)((uintptr_t)timerid << 1); struct timer_obj *timer = timer_id_get(timerid); rt_tick_t remaining; rt_uint32_t seconds, nanoseconds; @@ -1173,9 +1170,6 @@ RTM_EXPORT(timer_gettime); int timer_settime(timer_t timerid, int flags, const struct itimerspec *value, struct itimerspec *ovalue) { - // struct timer_obj *timer = (struct timer_obj *)((uintptr_t)timerid << 1); - - rt_kprintf("timerid %d\r\n", timerid); struct timer_obj *timer = timer_id_get(timerid); if (timer == NULL || rt_object_get_type(&timer->timer.parent) != RT_Object_Class_Timer || -- GitLab