diff --git a/kernel/base/core/los_task.c b/kernel/base/core/los_task.c index b1d5d9231a12a06a569d2d75a14af9c568eb5d85..14ee0598a7e009744ee897ad3cd5a4605f043e30 100644 --- a/kernel/base/core/los_task.c +++ b/kernel/base/core/los_task.c @@ -1249,19 +1249,19 @@ EXIT: return err; } -UINT32 OsUserTaskOperatePermissionsCheck(LosTaskCB *taskCB) +INT32 OsUserTaskOperatePermissionsCheck(const LosTaskCB *taskCB) { return OsUserProcessOperatePermissionsCheck(taskCB, OsCurrProcessGet()->processID); } -UINT32 OsUserProcessOperatePermissionsCheck(LosTaskCB *taskCB, UINT32 processID) +INT32 OsUserProcessOperatePermissionsCheck(const LosTaskCB *taskCB, UINT32 processID) { if (taskCB == NULL) { return LOS_EINVAL; } if (processID == OS_INVALID_VALUE) { - return OS_INVALID_VALUE; + return LOS_EINVAL; } if (taskCB->taskStatus & OS_TASK_STATUS_UNUSED) { diff --git a/kernel/base/include/los_task_pri.h b/kernel/base/include/los_task_pri.h index d2b27dc6ae5812aba94567b97e03db6dbbd00176..f5e399e4514dfbcb296c6ae2f3dc962d80583a15 100644 --- a/kernel/base/include/los_task_pri.h +++ b/kernel/base/include/los_task_pri.h @@ -323,8 +323,8 @@ extern UINT32 OsCreateUserTask(UINT32 processID, TSK_INIT_PARAM_S *initParam); extern INT32 OsSetTaskName(LosTaskCB *taskCB, const CHAR *name, BOOL setPName); extern VOID OsTaskCBRecycleToFree(VOID); extern VOID OsRunningTaskToExit(LosTaskCB *runTask, UINT32 status); -extern UINT32 OsUserTaskOperatePermissionsCheck(LosTaskCB *taskCB); -extern UINT32 OsUserProcessOperatePermissionsCheck(LosTaskCB *taskCB, UINT32 processID); +extern INT32 OsUserTaskOperatePermissionsCheck(const LosTaskCB *taskCB); +extern INT32 OsUserProcessOperatePermissionsCheck(const LosTaskCB *taskCB, UINT32 processID); extern INT32 OsTcbDispatch(LosTaskCB *stcb, siginfo_t *info); extern VOID OsWriteResourceEvent(UINT32 events); extern VOID OsWriteResourceEventUnsafe(UINT32 events); diff --git a/kernel/base/ipc/los_futex.c b/kernel/base/ipc/los_futex.c index 437381ec559e25fb3da26b99f50d80b606c3acf8..44de7a5b4792ead1da572d152483e50c63b06e01 100644 --- a/kernel/base/ipc/los_futex.c +++ b/kernel/base/ipc/los_futex.c @@ -112,16 +112,16 @@ STATIC VOID OsFutexShowTaskNodeAttr(const LOS_DL_LIST *futexList) LOS_DL_LIST *queueList = NULL; tempNode = OS_FUTEX_FROM_FUTEXLIST(futexList); - PRINTK("key(pid) : 0x%x(%d) : ->", tempNode->key, tempNode->pid); + PRINTK("key(pid) : 0x%x(%u) : ->", tempNode->key, tempNode->pid); for (queueList = &tempNode->queueList; ;) { lastNode = OS_FUTEX_FROM_QUEUELIST(queueList); if (!LOS_ListEmpty(&(lastNode->pendList))) { taskCB = OS_TCB_FROM_PENDLIST(LOS_DL_LIST_FIRST(&(lastNode->pendList))); - PRINTK(" %d(%d) ->", taskCB->taskID, taskCB->priority); + PRINTK(" %u(%u) ->", taskCB->taskID, taskCB->priority); } else { taskCB = LOS_DL_LIST_ENTRY(lastNode, LosTaskCB, futex); - PRINTK(" %d(%d) ->", taskCB->taskID, -1); + PRINTK(" %u(%d) ->", taskCB->taskID, -1); } queueList = queueList->pstNext; if (queueList == &tempNode->queueList) { diff --git a/kernel/base/mp/los_stat.c b/kernel/base/mp/los_stat.c index a0d25ca0af9e3f5dc98d069fabcb11dce6f930ea..2810c2ec491f21f98fe7fc45dd3f7850a521ca8f 100644 --- a/kernel/base/mp/los_stat.c +++ b/kernel/base/mp/los_stat.c @@ -173,7 +173,7 @@ LITE_OS_SEC_TEXT_MINOR VOID OsShellCmdDumpSched(VOID) affinity = (UINT32)taskCB->cpuAffiMask; - PRINTK("%-30s0x%-6x%+16lf ms %10d\n", taskCB->taskName, taskCB->taskID, + PRINTK("%-30s0x%-6x%+16lf ms %10u\n", taskCB->taskName, taskCB->taskID, (DOUBLE)(taskCB->schedStat.allRuntime) / NS_PER_MS, taskCB->schedStat.allContextSwitch); @@ -183,7 +183,7 @@ LITE_OS_SEC_TEXT_MINOR VOID OsShellCmdDumpSched(VOID) } PRINTK(" " - "CPU%d %+16lf ms %12d\n", cpuid, + "CPU%u %+16lf ms %12u\n", cpuid, (DOUBLE)(taskCB->schedStat.schedPercpu[cpuid].runtime) / NS_PER_MS, taskCB->schedStat.schedPercpu[cpuid].contexSwitch); } @@ -251,7 +251,7 @@ LITE_OS_SEC_TEXT_MINOR VOID OsMpStaticShow(UINT64 mpStaticPastTime) "---------- ---------- ---------- ----------\n"); for (cpuid = 0; cpuid < LOSCFG_KERNEL_CORE_NUM; cpuid++) { - PRINTK("CPU%d %+10lf%14d%14d%14d %+11lf %+11lf %+11lf%14d %+11lf\n", cpuid, + PRINTK("CPU%u %+10lf%14u%14u%14u %+11lf %+11lf %+11lf%14u %+11lf\n", cpuid, ((DOUBLE)(g_mpStatPercpu[cpuid].idleRuntime) / mpStaticPastTime) * DECIMAL_TO_PERCENTAGE, g_mpStatPercpu[cpuid].contexSwitch, g_mpStatPercpu[cpuid].hwiNum, diff --git a/syscall/process_syscall.c b/syscall/process_syscall.c index 916ccbcf9b12a1dab68622bb04bc34f1f288500e..59165d2b7e61931b79a3ab3449234f540250149c 100644 --- a/syscall/process_syscall.c +++ b/syscall/process_syscall.c @@ -43,7 +43,6 @@ #include "capability_api.h" #endif - static int OsPermissionToCheck(unsigned int pid, unsigned int who) { int ret = LOS_GetProcessGroupID(pid); @@ -78,8 +77,8 @@ static int OsUserTaskSchedulerSet(unsigned int tid, unsigned short policy, unsig return EINVAL; } - SCHEDULER_LOCK(intSave); LosTaskCB *taskCB = OS_TCB_FROM_TID(tid); + SCHEDULER_LOCK(intSave); ret = OsUserTaskOperatePermissionsCheck(taskCB); if (ret != LOS_OK) { SCHEDULER_UNLOCK(intSave); @@ -100,13 +99,14 @@ static int OsUserTaskSchedulerSet(unsigned int tid, unsigned short policy, unsig void SysSchedYield(int type) { + (void)type; + (void)LOS_TaskYield(); return; } int SysSchedGetScheduler(int id, int flag) { - LosTaskCB *taskCB = NULL; unsigned int intSave; int policy; int ret; @@ -116,15 +116,15 @@ int SysSchedGetScheduler(int id, int flag) return -EINVAL; } + LosTaskCB *taskCB = OS_TCB_FROM_TID(id); SCHEDULER_LOCK(intSave); - taskCB = OS_TCB_FROM_TID(id); ret = OsUserTaskOperatePermissionsCheck(taskCB); if (ret != LOS_OK) { SCHEDULER_UNLOCK(intSave); return -ret; } - policy = taskCB->policy; + policy = (int)taskCB->policy; SCHEDULER_UNLOCK(intSave); return policy; } @@ -158,8 +158,7 @@ int SysSchedSetScheduler(int id, int policy, int prio, int flag) int SysSchedGetParam(int id, int flag) { - LosTaskCB *taskCB = NULL; - int pri; + int prio; unsigned int intSave; if (flag < 0) { @@ -167,17 +166,17 @@ int SysSchedGetParam(int id, int flag) return -EINVAL; } + LosTaskCB *taskCB = OS_TCB_FROM_TID(id); SCHEDULER_LOCK(intSave); - taskCB = OS_TCB_FROM_TID(id); - pri = OsUserTaskOperatePermissionsCheck(taskCB); - if (pri != LOS_OK) { + prio = OsUserTaskOperatePermissionsCheck(taskCB); + if (prio != LOS_OK) { SCHEDULER_UNLOCK(intSave); - return -pri; + return -prio; } - pri = taskCB->priority; + prio = (int)taskCB->priority; SCHEDULER_UNLOCK(intSave); - return pri; + return prio; } if (id == 0) { @@ -894,17 +893,15 @@ unsigned int SysCreateUserThread(const TSK_ENTRY_FUNC func, const UserTaskParam int SysSetThreadArea(const char *area) { unsigned int intSave; - LosTaskCB *taskCB = NULL; - LosProcessCB *processCB = NULL; - unsigned int ret = LOS_OK; + int ret = LOS_OK; if (!LOS_IsUserAddress((unsigned long)(uintptr_t)area)) { return EINVAL; } + LosTaskCB *taskCB = OsCurrTaskGet(); SCHEDULER_LOCK(intSave); - taskCB = OsCurrTaskGet(); - processCB = OS_PCB_FROM_PID(taskCB->processID); + LosProcessCB *processCB = OS_PCB_FROM_PID(taskCB->processID); if (processCB->processMode != OS_USER_MODE) { ret = EPERM; goto OUT; @@ -925,20 +922,19 @@ int SysUserThreadSetDetach(unsigned int taskID) { unsigned int intSave; int ret; - LosTaskCB *taskCB = NULL; if (OS_TID_CHECK_INVALID(taskID)) { return EINVAL; } + LosTaskCB *taskCB = OS_TCB_FROM_TID(taskID); SCHEDULER_LOCK(intSave); - taskCB = OS_TCB_FROM_TID(taskID); ret = OsUserTaskOperatePermissionsCheck(taskCB); if (ret != LOS_OK) { goto EXIT; } - ret = OsTaskSetDetachUnsafe(taskCB); + ret = (int)OsTaskSetDetachUnsafe(taskCB); EXIT: SCHEDULER_UNLOCK(intSave); @@ -948,7 +944,7 @@ EXIT: int SysUserThreadDetach(unsigned int taskID) { unsigned int intSave; - unsigned int ret; + int ret; if (OS_TID_CHECK_INVALID(taskID)) { return EINVAL; @@ -961,8 +957,7 @@ int SysUserThreadDetach(unsigned int taskID) return ret; } - ret = LOS_TaskDelete(taskID); - if (ret != LOS_OK) { + if (LOS_TaskDelete(taskID) != LOS_OK) { return ESRCH; } @@ -972,21 +967,20 @@ int SysUserThreadDetach(unsigned int taskID) int SysThreadJoin(unsigned int taskID) { unsigned int intSave; - unsigned int ret; - LosTaskCB *taskCB = NULL; + int ret; if (OS_TID_CHECK_INVALID(taskID)) { return EINVAL; } + LosTaskCB *taskCB = OS_TCB_FROM_TID(taskID); SCHEDULER_LOCK(intSave); - taskCB = OS_TCB_FROM_TID(taskID); ret = OsUserTaskOperatePermissionsCheck(taskCB); if (ret != LOS_OK) { goto EXIT; } - ret = OsTaskJoinPendUnsafe(OS_TCB_FROM_TID(taskID)); + ret = (int)OsTaskJoinPendUnsafe(OS_TCB_FROM_TID(taskID)); EXIT: SCHEDULER_UNLOCK(intSave);