diff --git a/apps/lms/src/sample_usr_lms.c b/apps/lms/src/sample_usr_lms.c index 208efb2f305541bbd22baf82fecaf824dc05c18e..f722db10637aedbbf1bd5b01234d93441865d81f 100755 --- a/apps/lms/src/sample_usr_lms.c +++ b/apps/lms/src/sample_usr_lms.c @@ -180,7 +180,7 @@ static void LmsFreeTest(void) printf("\n-------- LmsFreeTest Start --------\n"); char *buf = (char *)malloc(16); printf("[LmsFreeTest] malloc addr:%p size:%d\n", buf, 16); - printf("[LmsFreeTest] free addr:%p\n", buf, 16); + printf("[LmsFreeTest] free addr:%p size:%d\n", buf, 16); free(buf); printf("[LmsFreeTest] Use after free error should be triggered, read addr:%p range[1,1]\n", buf); BufReadTest(buf, 1, 1); @@ -204,5 +204,6 @@ int main(int argc, char * const * argv) LmsStrcpyTest(); LmsStrcatTest(); LmsFreeTest(); + free(tmp); printf("\n############### Lms Test End ###############\n"); } \ No newline at end of file diff --git a/apps/shell/src/shcmd.c b/apps/shell/src/shcmd.c index d8563e3a95d248b2be1a5ba189d9fc920039abd3..5142153c8011bd2bc16068af60e311748e3d504a 100644 --- a/apps/shell/src/shcmd.c +++ b/apps/shell/src/shcmd.c @@ -36,7 +36,6 @@ #include "dirent.h" #include "securec.h" - #define SHELL_INIT_MAGIC_FLAG 0xABABABAB #define CTRL_C 0x03 /* 0x03: ctrl+c ASCII */ @@ -585,7 +584,6 @@ END: unsigned int OsCmdExec(CmdParsed *cmdParsed, char *cmdStr) { - /* TODO: complete the usrspace command */ unsigned int ret = SH_OK; if (cmdParsed && cmdStr) { ret = SH_NOK; diff --git a/fs/proc/src/proc_file.c b/fs/proc/src/proc_file.c index 9eebcd4633d93dee209dad2551efa852bd156aab..408fc2d96623743d59115ec9c36514466d4dd754 100644 --- a/fs/proc/src/proc_file.c +++ b/fs/proc/src/proc_file.c @@ -519,7 +519,7 @@ int ProcOpen(struct ProcFile *procFile) static int ProcRead(struct ProcDirEntry *pde, char *buf, size_t len) { - if (pde == NULL || pde == NULL || pde->pf == NULL) { + if (pde == NULL || pde->pf == NULL) { return PROC_ERROR; } struct ProcFile *procFile = pde->pf; diff --git a/fs/vfs/vnode.c b/fs/vfs/vnode.c index c85665ac06b24918debe713ae565e4318c909b90..494ab091480d7f438616d7aa9af63bdbbce39a9f 100644 --- a/fs/vfs/vnode.c +++ b/fs/vfs/vnode.c @@ -380,6 +380,11 @@ int VnodeLookupAt(const char *path, struct Vnode **result, uint32_t flags, struc if (orgVnode != NULL) { startVnode = orgVnode; normalizedPath = strdup(path); + if (normalizedPath == NULL) { + PRINT_ERR("[VFS]lookup failed, strdup err\n"); + ret = -EINVAL; + goto OUT_FREE_PATH; + } } else { ret = PreProcess(path, &startVnode, &normalizedPath); if (ret != LOS_OK) { diff --git a/kernel/base/core/los_process.c b/kernel/base/core/los_process.c index ddfd9fe485d694325a8eb49f5067f1be0b0ac9f4..161a3d163a81693b795d9ba6d151a7b07c9903cf 100644 --- a/kernel/base/core/los_process.c +++ b/kernel/base/core/los_process.c @@ -2002,6 +2002,8 @@ LITE_OS_SEC_TEXT VOID LOS_Exit(INT32 status) { UINT32 intSave; + (void)status; + /* The exit of a kernel - state process must be kernel - state and all threads must actively exit */ LosProcessCB *processCB = OsCurrProcessGet(); SCHEDULER_LOCK(intSave); diff --git a/kernel/base/sched/sched_sq/los_sched.c b/kernel/base/sched/sched_sq/los_sched.c index c0a4710054aae7af0178de9eb0ae3f99f4c1516f..622c8fe6187c63824ed91f67061fc3ef10e11662 100644 --- a/kernel/base/sched/sched_sq/los_sched.c +++ b/kernel/base/sched/sched_sq/los_sched.c @@ -578,7 +578,7 @@ BOOL OsSchedModifyTaskSchedParam(LosTaskCB *taskCB, UINT16 policy, UINT16 priori } taskCB->priority = priority; - OsHookCall(LOS_HOOK_TYPE_TASK_PRIMODIFY, taskCB, taskCB->priority); + OsHookCall(LOS_HOOK_TYPE_TASK_PRIMODIFY, taskCB, taskCB->priority); if (taskCB->taskStatus & OS_TASK_STATUS_INIT) { OsSchedTaskEnQueue(taskCB); return TRUE; @@ -771,7 +771,9 @@ BOOL OsSchedSwtmrTimeListFind(SCHED_TL_FIND_FUNC checkFunc, UINTPTR arg) for (UINT16 cpuid = 0; cpuid < LOSCFG_KERNEL_CORE_NUM; cpuid++) { SchedRunQue *rq = OsSchedRunQueByID(cpuid); SortLinkAttribute *swtmrSortLink = &rq->swtmrSortLink; - return SchedSwtmrRunQueFind(swtmrSortLink, checkFunc, arg); + if (SchedSwtmrRunQueFind(swtmrSortLink, checkFunc, arg)) { + return TRUE; + } } return FALSE; } diff --git a/kernel/common/console.c b/kernel/common/console.c index 78d075819f3a8681a08108d22f8465bc8b6589a3..4f072897ba9f602c2e334e7805ae46d63976da5f 100644 --- a/kernel/common/console.c +++ b/kernel/common/console.c @@ -1325,7 +1325,9 @@ INT32 system_console_init(const CHAR *deviceName) LOS_SpinLockSave(&g_consoleSpin, &intSave); (VOID)OsConsoleDelete(consoleCB); g_console[consoleID - 1] = NULL; - g_taskConsoleIDArray[OsCurrTaskGet()->taskID] = 0; + if (OsCurrTaskGet() != NULL) { + g_taskConsoleIDArray[OsCurrTaskGet()->taskID] = 0; + } LOS_SpinUnlockRestore(&g_consoleSpin, intSave); return VFS_ERROR; } diff --git a/lib/libscrew/src/los_rbtree.c b/lib/libscrew/src/los_rbtree.c index 6c2a6702e509041cedd8e3eb845d0240ca8d20ca..c9e9b43cf554ab21dd69a7b95c44db3585a8950f 100644 --- a/lib/libscrew/src/los_rbtree.c +++ b/lib/libscrew/src/los_rbtree.c @@ -52,7 +52,7 @@ STATIC VOID OsRbLeftRotateNode(LosRbTree *pstTree, LosRbNode *pstX) LosRbNode *pstNilT = NULL; LosRbNode *pstParent = NULL; - if (NULL == pstTree || NULL == pstX) { + if (pstTree == NULL || pstX == NULL) { return; } pstNilT = &(pstTree->stNilT); diff --git a/net/lwip-2.1/enhancement/src/api_shell.c b/net/lwip-2.1/enhancement/src/api_shell.c index 01f95661bd0aaa29252b912364505464c64a68c6..51426bb6768bde56de7ef91924e1a7672325321b 100644 --- a/net/lwip-2.1/enhancement/src/api_shell.c +++ b/net/lwip-2.1/enhancement/src/api_shell.c @@ -3015,7 +3015,7 @@ int netstat_netconn_sendq(struct netconn *conn) retVal = netstat_tcp_sendq(conn->pcb.tcp); break; case NETCONN_RAW: - retVal = 0; /* todo */ + retVal = 0; break; #if PF_PKT_SUPPORT case NETCONN_PKT_RAW: diff --git a/net/lwip-2.1/enhancement/src/fixme.c b/net/lwip-2.1/enhancement/src/fixme.c index 5bb6c3f768a836855c36034968e232febc22c3d2..859251c4a8ff912329692219be51d333fc3ab23f 100644 --- a/net/lwip-2.1/enhancement/src/fixme.c +++ b/net/lwip-2.1/enhancement/src/fixme.c @@ -144,7 +144,7 @@ err_t netifapi_dhcps_stop(struct netif *netif) */ static void tcp_unlock_accept(ip6_addr_t *ipaddr) { - // FIXME + } static void netif_ip6_addr_setinvalid(struct netif *netif, const ip6_addr_t *addr6) @@ -327,26 +327,22 @@ err_t netif_set_hwaddr(struct netif *netif, const unsigned char *hw_addr, int hw err_t etharp_update_arp_entry(struct netif *netif, const ip4_addr_t *ipaddr, struct eth_addr *ethaddr, u8_t flags) { - // FIXME return 0; } err_t etharp_delete_arp_entry(struct netif *netif, ip4_addr_t *ipaddr) { - // FIXME return 0; } err_t lwip_dns_setserver(u8_t numdns, ip_addr_t *dnsserver) { - // FIXME return 0; } err_t lwip_dns_getserver(u8_t numdns, ip_addr_t *dnsserver) { - // FIXME return 0; } @@ -372,7 +368,6 @@ sys_sem_t dup_addr_detect; int lwip_sntp_start(int server_num, char **sntp_server, struct timeval *time) { - // FIXME return 0; } diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_025.c b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_025.c index e582f5df6685f314db43ad4a92f5dde6960f7d88..51a81143cf630f695fcb1f38a8a051727a9632ff 100644 --- a/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_025.c +++ b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_025.c @@ -69,7 +69,7 @@ static UINT32 Testcase(VOID) tickNum = (osEndTime - osStartTime) * LOSCFG_BASE_CORE_TICK_PER_SECOND / OS_SYS_CLOCK; - if (tickNum < (10 - 2) && tickNum > (10 + 2)) { // when tick num in 10 - 2 or 10 + 2 interval + if (tickNum < (10 - 2) || tickNum > (10 + 2)) { // when tick num in 10 - 2 or 10 + 2 interval ICUNIT_ASSERT_EQUAL(tickNum, 0, tickNum); } ret = LOS_EventClear(&g_event, 0); diff --git a/testsuites/unittest/basic/exc/full/it_test_fexecve_001.cpp b/testsuites/unittest/basic/exc/full/it_test_fexecve_001.cpp index e4cfa5eb891eb0db699ee126f350bfc93a6bb14a..7aeb897a63f67698e8dbe78fe49a25ac55dfb2b4 100644 --- a/testsuites/unittest/basic/exc/full/it_test_fexecve_001.cpp +++ b/testsuites/unittest/basic/exc/full/it_test_fexecve_001.cpp @@ -82,16 +82,21 @@ static int TestCase(void) printf("fd=%d\n", fd); if (fd == -1) { perror("openls"); + munmap(p, st.st_size); return -1; } rc = read(fd, p, st.st_size); if (rc == -1) { perror("read"); + munmap(p, st.st_size); + close(shmFd); return -1; } if (rc != st.st_size) { fputs("Strange situation!\n", stderr); + munmap(p, st.st_size); + close(shmFd); return -1; } diff --git a/testsuites/unittest/basic/mem/shm/full/shm_test_013.cpp b/testsuites/unittest/basic/mem/shm/full/shm_test_013.cpp index 72375cfe2a6b95b440ee9021c2fe085e99dd23e6..19fb4fc64440f228f125081f73d51e1aea22dc50 100644 --- a/testsuites/unittest/basic/mem/shm/full/shm_test_013.cpp +++ b/testsuites/unittest/basic/mem/shm/full/shm_test_013.cpp @@ -44,9 +44,10 @@ static int testcase(void) ICUNIT_ASSERT_NOT_EQUAL(shmfd, -1, shmfd); writebuf = (char*)malloc(pageSize); + ICUNIT_ASSERT_NOT_EQUAL(writebuf, NULL, writebuf); readbuf = (char*)malloc(pageSize); ICUNIT_ASSERT_NOT_EQUAL(readbuf, NULL, readbuf); - ICUNIT_ASSERT_NOT_EQUAL(writebuf, NULL, writebuf); + memset_s(writebuf, pageSize, 0xf, pageSize); count = write(shmfd, writebuf, pageSize); diff --git a/testsuites/unittest/common/osTest.cpp b/testsuites/unittest/common/osTest.cpp index 3b0ca940d96f0ad979f58a0a4e3557359fb1f526..f1e70b691b450fca6875ebf231360f87286697fd 100644 --- a/testsuites/unittest/common/osTest.cpp +++ b/testsuites/unittest/common/osTest.cpp @@ -460,6 +460,7 @@ int RemoveDir(const char *dir) ret = sprintf_s(dir_name, sizeof(dir_name), "%s/%s", dir, dp->d_name); if (ret < 0) { perror("sprintf dir_name error"); + closedir(dirp); return -1; } RemoveDir(dir_name); diff --git a/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_204.cpp b/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_204.cpp index 1206baffb25b356e4109119682aa83fe826e1779..264dec4eebb96dcd365415355fa33ea851b7a035 100644 --- a/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_204.cpp +++ b/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_204.cpp @@ -55,8 +55,6 @@ static int TestCase(void) ret = unlinkat(dirFd, FILEPATH, AT_REMOVEDIR); ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1); - return JFFS_NO_ERROR; - EXIT1: close(fd); unlink(DIRPATH); diff --git a/testsuites/unittest/fs/jffs/vfs_jffs_test.cpp b/testsuites/unittest/fs/jffs/vfs_jffs_test.cpp index 4bd98f916743361407fda5f5d64862f61b2eeb66..f71c5f49572b5807affb49fa3d9da4b6c960f663 100644 --- a/testsuites/unittest/fs/jffs/vfs_jffs_test.cpp +++ b/testsuites/unittest/fs/jffs/vfs_jffs_test.cpp @@ -353,7 +353,7 @@ INT32 JffsFixWrite(CHAR *path, INT64 fileSize, INT32 writeSize, INT32 interfaceT gettimeofday(&testTime2, 0); perTime = (testTime2.tv_sec - testTime1.tv_sec) * USECS_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec); - printf("fix_Write TaskID:%3d,sucess to fclose the %s ,task:%d ms,\n", taskId, path, MSECS_PER_SEC / MSECS_PER_SEC); + printf("fix_Write TaskID:%3d,sucess to fclose the %s ,task:%d ms,\n", taskId, path, (perTime / USECS_PER_SEC) * MSECS_PER_SEC); free(writeBuf); @@ -1000,7 +1000,7 @@ public: }; #if defined(LOSCFG_USER_TEST_FULL) /* * - * @tc.name: IO_TEST_FACCESSAT_001 + * @tc.name: IO_TEST_FACCESSAT_001 * @tc.desc: normal tests for faccessat * @tc.type: FUNC * @tc.require: AR000EEMQ9 diff --git a/testsuites/unittest/libc/io/full/It_stdio_hasmntopt_001.cpp b/testsuites/unittest/libc/io/full/It_stdio_hasmntopt_001.cpp index 2169f01c1849b89d95531af289971415b1c6da1a..f493a15c20b7980e59d5f0c52fb23593601b6214 100644 --- a/testsuites/unittest/libc/io/full/It_stdio_hasmntopt_001.cpp +++ b/testsuites/unittest/libc/io/full/It_stdio_hasmntopt_001.cpp @@ -35,6 +35,7 @@ static UINT32 testcase(VOID) struct mntent* mnt = nullptr; struct mntent* mnt_new = nullptr; FILE *fp = nullptr; + FILE *fp2 = nullptr; char *argv[2] = {nullptr}; argv[0] = "/etc/fstab"; argv[1] = "errors"; @@ -45,14 +46,14 @@ static UINT32 testcase(VOID) char *pathList[] = {"/etc/fstab"}; char *streamList[] = {(char *)fileWords}; int streamLen[] = {sizeof(fileWords)}; - + int flag = PrepareFileEnv(pathList, streamList, streamLen, 1); if (flag != 0) { printf("error: need some env file, but prepare is not ok"); (VOID)RecoveryFileEnv(pathList, 1); return -1; } - + mnt_new = (struct mntent *)malloc(sizeof(struct mntent)); mnt_new->mnt_fsname = "UUID=c4992556-a86e-45e8-ba5f-190b16a9073x"; mnt_new->mnt_dir = "/usr1"; @@ -64,6 +65,7 @@ static UINT32 testcase(VOID) fp = setmntent("/etc/fstab", "r"); if (!fp) { printf("fp=0x%x\n", fp); + free(mnt_new); return LOS_NOK; } @@ -81,7 +83,8 @@ static UINT32 testcase(VOID) /* test the addmntent below */ fp = setmntent(argv[0], "a"); - if (fopen("/lib/libc.so", "r")) { + fp2 = fopen("/lib/libc.so", "r"); + if (fp2 != NULL) { printf("aha I found you are OHOS!!!\n"); if (addmntent(fp, mnt_new)) { printf("a new mnt is added to %s\n", argv[0]); @@ -91,6 +94,9 @@ static UINT32 testcase(VOID) if (fp != NULL) { endmntent(fp); } + if (fp2 != NULL) { + fclose(fp2); + } (VOID)RecoveryFileEnv(pathList, 1); return LOS_OK; } diff --git a/testsuites/unittest/libc/sys/full/sys_test_026.cpp b/testsuites/unittest/libc/sys/full/sys_test_026.cpp index 80b9244b7b553bc6326734ad9ab21c09c0ed9473..106bce0cfabf21014b1c28052b86d4b8c905c879 100644 --- a/testsuites/unittest/libc/sys/full/sys_test_026.cpp +++ b/testsuites/unittest/libc/sys/full/sys_test_026.cpp @@ -34,7 +34,7 @@ static int TestCase(void) { char *name = getlogin(); ICUNIT_ASSERT_NOT_EQUAL(name, "USER1", NULL); - int ret = getlogin_r(name, sizeof(name)); + int ret = getlogin_r(name, strlen(name) + 1); ICUNIT_ASSERT_EQUAL(ret, 6, ret); ret = setenv("LOGNAME", "USER1", 1); ICUNIT_ASSERT_EQUAL(ret, 0, ret); diff --git a/testsuites/unittest/libc/sys/smoke/sys_test_013.cpp b/testsuites/unittest/libc/sys/smoke/sys_test_013.cpp index 43402cab5563998056b69a892287cdf6cc972dbf..97f9b074ce564d31ebeee7be8887e17a98956182 100644 --- a/testsuites/unittest/libc/sys/smoke/sys_test_013.cpp +++ b/testsuites/unittest/libc/sys/smoke/sys_test_013.cpp @@ -39,7 +39,10 @@ struct q { static struct q *New(int i) { struct q *q = (struct q *)malloc(sizeof *q); - q->i = i; + if (q != NULL) { + q->i = i; + } + return q; } diff --git a/testsuites/unittest/libc/time/timer/time_timer_test.cpp b/testsuites/unittest/libc/time/timer/time_timer_test.cpp index dc2d96484664734f62105a373ec9644816c82570..dae658f5fd769d5f33e1035b1cbd9dfa92dffdb8 100644 --- a/testsuites/unittest/libc/time/timer/time_timer_test.cpp +++ b/testsuites/unittest/libc/time/timer/time_timer_test.cpp @@ -76,17 +76,6 @@ HWTEST_F(TimeTimerTest, TimerTest003, TestSize.Level0) TimerTest003(); } -/* * - * @tc.name: TimerTest004 - * @tc.desc: function for TimeTimerTest - * @tc.type: FUNC - * @tc.require: AR000EEMQ9 - */ -/*HWTEST_F(TimeTimerTest, TimerTest004, TestSize.Level0) -{ - TimerTest004(); // TODO: musl sigaction handler have only one param. -}*/ - /* * * @tc.name: TimerTest005 * @tc.desc: function for timer_create SIGEV_THREAD.