2 Star 0 Fork 1K

bes_adaptation/kernel_liteos_a

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
a.diff 2.31 KB
一键复制 编辑 原始数据 按行查看 历史
Harylee 提交于 2022-04-28 15:57 . fix: update newlib
diff --git a/compat/posix/src/time.c b/compat/posix/src/time.c
index 9935914..7e5da23 100644
--- a/compat/posix/src/time.c
+++ b/compat/posix/src/time.c
@@ -719,6 +719,7 @@ typedef struct {
static VOID SwtmrProc(UINTPTR tmrArg)
{
+#ifdef LOSCFG_KERNEL_VM
INT32 sig, ret;
UINT32 intSave;
pid_t pid;
@@ -763,13 +764,16 @@ static VOID SwtmrProc(UINTPTR tmrArg)
EXIT:
PRINT_ERR("Dispatch signals failed!, ret: %d\r\n", ret);
return;
+#endif
}
int timer_create(clockid_t clockID, struct sigevent *restrict evp, timer_t *restrict timerID)
{
UINT32 ret;
UINT16 swtmrID;
- UINTPTR *arg = NULL;
+#ifdef LOSCFG_SECURITY_VID
+ UINT16 vid;
+#endif
if (!timerID || (clockID != CLOCK_REALTIME) || !evp) {
errno = EINVAL;
@@ -781,20 +785,21 @@ int timer_create(clockid_t clockID, struct sigevent *restrict evp, timer_t *rest
return -1;
}
- arg = (UINTPTR *)malloc(sizeof(UINTPTR));
- if (arg == NULL) {
- errno = ENOMEM;
- return -1;
- }
-
- arg = evp ? evp->sigev_value.sival_ptr : NULL;
- ret = LOS_SwtmrCreate(1, LOS_SWTMR_MODE_ONCE, (SWTMR_PROC_FUNC)evp->sigev_notify_function, &swtmrID, (UINTPTR)arg);
+ ret = LOS_SwtmrCreate(1, LOS_SWTMR_MODE_ONCE, (SWTMR_PROC_FUNC)evp->sigev_notify_function, &swtmrID,
+ (UINTPTR)evp->sigev_value.sival_ptr);
if (ret != LOS_OK) {
errno = (ret == LOS_ERRNO_SWTMR_MAXSIZE) ? EAGAIN : EINVAL;
- free(arg);
return -1;
}
+#ifdef LOSCFG_SECURITY_VID
+ vid = AddNodeByRid(swtmrID);
+ if (vid == MAX_INVALID_TIMER_VID) {
+ (VOID)LOS_SwtmrDelete(swtmrID);
+ return -1;
+ }
+ swtmrID = vid;
+#endif
*timerID = (timer_t)(UINTPTR)swtmrID;
return 0;
}
@@ -858,6 +863,7 @@ int timer_delete(timer_t timerID)
{
UINT16 swtmrID = (UINT16)(UINTPTR)timerID;
VOID *arg = NULL;
+ UINTPTR swtmrProc;
#ifdef LOSCFG_SECURITY_VID
swtmrID = GetRidByVid(swtmrID);
@@ -867,10 +873,11 @@ int timer_delete(timer_t timerID)
}
arg = (VOID *)OS_SWT_FROM_SID(swtmrID)->uwArg;
+ swtmrProc = (UINTPTR)OS_SWT_FROM_SID(swtmrID)->pfnHandler;
if (LOS_SwtmrDelete(swtmrID)) {
goto ERROUT;
}
- if (arg != NULL) {
+ if ((swtmrProc == (UINTPTR)SwtmrProc) && (arg != NULL)) {
free(arg);
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/arch_adaptation/kernel_liteos_a.git
git@gitee.com:arch_adaptation/kernel_liteos_a.git
arch_adaptation
kernel_liteos_a
kernel_liteos_a
master

搜索帮助

D67c1975 1850385 1daf7b77 1850385