diff --git a/apps/lms/src/sample_usr_lms.c b/apps/lms/src/sample_usr_lms.c index 8ecadc87f653342549cea5249998f424ff087deb..c8ef15d63c989ababf52d1158909d12e159140d0 100644 --- a/apps/lms/src/sample_usr_lms.c +++ b/apps/lms/src/sample_usr_lms.c @@ -53,7 +53,9 @@ static void LmsMallocTest(void) #define TEST_SIZE 16 printf("\n-------- LmsMallocTest Start --------\n"); char *buf = (char *)malloc(TEST_SIZE); - + if (buf == NULL) { + return; + } printf("[LmsMallocTest] read overflow & underflow error should be triggered, read range[-1, TEST_SIZE]\n"); BufReadTest(buf, -1, TEST_SIZE); printf("[LmsMallocTest] write overflow error should be triggered, write range[0, TEST_SIZE]\n"); @@ -88,6 +90,9 @@ static void LmsCallocTest(void) #define TEST_SIZE 16 printf("\n-------- LmsCallocTest Start --------\n"); char *buf = (char *)calloc(4, 4); /* 4: test size */ + if (buf == NULL) { + return; + } printf("[LmsCallocTest] read overflow & underflow error should be triggered, read range[-1, TEST_SIZE]\n"); BufReadTest(buf, -1, TEST_SIZE); free(buf); @@ -99,6 +104,9 @@ static void LmsVallocTest(void) #define TEST_SIZE 4096 printf("\n-------- LmsVallocTest Start --------\n"); char *buf = (char *)valloc(TEST_SIZE); + if (buf == NULL) { + return; + } printf("[LmsVallocTest] read overflow & underflow error should be triggered, read range[-1, TEST_SIZE]\n"); BufReadTest(buf, -1, TEST_SIZE); free(buf); @@ -111,6 +119,9 @@ static void LmsAlignedAllocTest(void) #define TEST_SIZE 128 printf("\n-------- LmsAlignedAllocTest Start --------\n"); char *buf = (char *)aligned_alloc(TEST_ALIGN_SIZE, TEST_SIZE); + if (buf == NULL) { + return; + } printf("[LmsAlignedAllocTest] read overflow & underflow error should be triggered, read range[-1,128]\n"); BufReadTest(buf, -1, 128); free(buf); @@ -122,6 +133,9 @@ static void LmsMemsetTest(void) #define TEST_SIZE 32 printf("\n-------- LmsMemsetTest Start --------\n"); char *buf = (char *)malloc(TEST_SIZE); + if (buf == NULL) { + return; + } printf("[LmsMemsetTest] memset overflow & underflow error should be triggered, memset size:%d\n", TEST_SIZE + 1); memset(buf, 0, TEST_SIZE + 1); free(buf); @@ -133,6 +147,9 @@ static void LmsMemcpyTest(void) #define TEST_SIZE 20 printf("\n-------- LmsMemcpyTest Start --------\n"); char *buf = (char *)malloc(TEST_SIZE); + if (buf == NULL) { + return; + } char localBuf[32] = {0}; /* 32: test size */ printf("[LmsMemcpyTest] memcpy overflow error should be triggered, memcpy size:%d\n", TEST_SIZE + 1); memcpy(buf, localBuf, TEST_SIZE + 1); @@ -145,6 +162,9 @@ static void LmsMemmoveTest(void) #define TEST_SIZE 20 printf("\n-------- LmsMemmoveTest Start --------\n"); char *buf = (char *)malloc(TEST_SIZE); + if (buf == NULL) { + return; + } printf("[LmsMemmoveTest] memmove overflow error should be triggered\n"); memmove(buf + 12, buf, 10); /* 12 and 10: test size */ free(buf); @@ -156,6 +176,9 @@ static void LmsStrcpyTest(void) #define TEST_SIZE 16 printf("\n-------- LmsStrcpyTest Start --------\n"); char *buf = (char *)malloc(TEST_SIZE); + if (buf == NULL) { + return; + } char *testStr = "bbbbbbbbbbbbbbbbb"; printf("[LmsStrcpyTest] strcpy overflow error should be triggered, src string buf size:%d\n", strlen(testStr) + 1); strcpy(buf, testStr); @@ -168,6 +191,9 @@ static void LmsStrcatTest(void) #define TEST_SIZE 16 printf("\n-------- LmsStrcatTest Start --------\n"); char *buf = (char *)malloc(TEST_SIZE); + if (buf == NULL) { + return; + } buf[0] = 'a'; buf[1] = 'b'; buf[2] = 0; @@ -185,6 +211,9 @@ static void LmsFreeTest(void) #define TEST_SIZE 16 printf("\n-------- LmsFreeTest Start --------\n"); char *buf = (char *)malloc(TEST_SIZE); + if (buf == NULL) { + return; + } printf("[LmsFreeTest] free size:%d\n", TEST_SIZE); free(buf); printf("[LmsFreeTest] Use after free error should be triggered, read range[1,1]\n"); @@ -200,6 +229,9 @@ int main(int argc, char * const *argv) (void)argv; printf("\n############### Lms Test start ###############\n"); char *tmp = (char *)malloc(5000); /* 5000: test mem size */ + if (tmp == NULL) { + return; + } LmsMallocTest(); LmsReallocTest(); LmsCallocTest(); diff --git a/drivers/char/random/src/random_hw.c b/drivers/char/random/src/random_hw.c index a290a5864573532a58fc3919bb26e10f415ba54f..04934a1426629444781a7931eeee61305d37e786 100644 --- a/drivers/char/random/src/random_hw.c +++ b/drivers/char/random/src/random_hw.c @@ -41,7 +41,7 @@ void RandomOperationsInit(const RandomOperations *r) if (r != NULL) { (void)memcpy_s(&g_randomOp, sizeof(RandomOperations), r, sizeof(RandomOperations)); } else { - PRINT_ERR("param is invalid\n", __FUNCTION__, __LINE__); + PRINT_ERR("%s %d param is invalid\n", __FUNCTION__, __LINE__); } return; } diff --git a/fs/patchfs/los_patchfs.c b/fs/patchfs/los_patchfs.c index 82b621a43a561bbcc3170d68d6463281c0ba9dd2..04346c6a9fb9e828184f8c2719463fe368a6cb98 100644 --- a/fs/patchfs/los_patchfs.c +++ b/fs/patchfs/los_patchfs.c @@ -55,14 +55,15 @@ INT32 OsMountPatchFs(VOID) } partInfo.fsType = strdup(FS_TYPE); if (partInfo.fsType == NULL) { - return LOS_NOK; + ret = LOS_NOK; + goto EXIT; } partInfo.startAddr = PATCHFS_FLASH_ADDR; partInfo.partSize = PATCHFS_FLASH_SIZE; #else ret = GetPartitionInfo(&partInfo); if (ret != LOS_OK) { - return ret; + goto EXIT; } partInfo.startAddr = (partInfo.startAddr >= 0) ? partInfo.startAddr : PATCHFS_FLASH_ADDR; partInfo.partSize = (partInfo.partSize >= 0) ? partInfo.partSize : PATCHFS_FLASH_SIZE; @@ -71,7 +72,7 @@ INT32 OsMountPatchFs(VOID) ret = LOS_NOK; partInfo.devName = strdup(PATCH_FLASH_DEV_NAME); if (partInfo.devName == NULL) { - return LOS_NOK; + goto EXIT; } const CHAR *devName = GetDevNameOfPartition(&partInfo); if (devName != NULL) { @@ -92,9 +93,13 @@ INT32 OsMountPatchFs(VOID) ResetDevNameofPartition(&partInfo); } +EXIT: free(partInfo.devName); + partInfo.devName = NULL; free(partInfo.storageType); + partInfo.storageType = NULL; free(partInfo.fsType); + partInfo.fsType = NULL; return ret; } diff --git a/fs/rootfs/los_bootargs.c b/fs/rootfs/los_bootargs.c index 82d02c22423b7b038ac6a0051dc55c29b9c4d04e..c6e2a680331f3ac4024dc8f266417f5349e21df2 100644 --- a/fs/rootfs/los_bootargs.c +++ b/fs/rootfs/los_bootargs.c @@ -214,7 +214,7 @@ UINT64 LOS_SizeStrToNum(CHAR *value) UINT64 num = 0; /* If the string is a hexadecimal value */ - if (sscanf_s(value, "0x%x", &num) > 0) { + if (sscanf_s(value, "0x%llx", &num) > 0) { value += strlen("0x"); if (strspn(value, "0123456789abcdefABCDEF") < strlen(value)) { goto ERROUT; @@ -247,4 +247,4 @@ UINT64 LOS_SizeStrToNum(CHAR *value) ERROUT: PRINT_ERR("Invalid value string \"%s\"!\n", value); return num; -} \ No newline at end of file +} diff --git a/fs/rootfs/los_rootfs.c b/fs/rootfs/los_rootfs.c index 58cbce125a63a5cecd3d4094984a69300cd8af21..a81c0163cf5ad75bd3851ee36af0351969b3a25d 100644 --- a/fs/rootfs/los_rootfs.c +++ b/fs/rootfs/los_rootfs.c @@ -327,7 +327,7 @@ STATIC INT32 CheckValidation(UINT64 rootAddr, UINT64 rootSize, UINT64 userAddr, if ((rootAddr & (alignSize - 1)) || (rootSize & (alignSize - 1)) || (userAddr & (alignSize - 1)) || (userSize & (alignSize - 1))) { - PRINT_ERR("The address or size value should be 0x%x aligned!\n", alignSize); + PRINT_ERR("The address or size value should be 0x%llx aligned!\n", alignSize); return LOS_NOK; } @@ -371,4 +371,4 @@ INT32 OsMountRootfs() } return LOS_OK; -} \ No newline at end of file +} diff --git a/fs/vfs/vfs_cmd/vfs_shellcmd.c b/fs/vfs/vfs_cmd/vfs_shellcmd.c index 77cad26dfb1cf8486020144541247f3d2c662724..67c175d14feb071bbbee7041e3f89729bf7d8d71 100644 --- a/fs/vfs/vfs_cmd/vfs_shellcmd.c +++ b/fs/vfs/vfs_cmd/vfs_shellcmd.c @@ -654,7 +654,7 @@ static int os_shell_cmd_do_cp(const char *src_filepath, const char *dst_filename char *dst_filepath = NULL; char *buf = NULL; const char *filename = NULL; - size_t r_size, w_size; + ssize_t r_size, w_size; int src_fd = -1; int dst_fd = -1; struct stat stat_buf; @@ -1391,8 +1391,8 @@ int checkNum(const char *arg) #ifdef LOSCFG_KERNEL_SYSCALL int osShellCmdSu(int argc, const char **argv) { - unsigned int su_uid; - unsigned int su_gid; + int su_uid; + int su_gid; if (argc == 0) { diff --git a/kernel/base/mem/tlsf/los_memory.c b/kernel/base/mem/tlsf/los_memory.c index 92e19659666087542b0dd29eba8b8ac127c4675b..20221c992c11397c2e10f7642303c2493e0ea2e8 100644 --- a/kernel/base/mem/tlsf/los_memory.c +++ b/kernel/base/mem/tlsf/los_memory.c @@ -1748,7 +1748,7 @@ STATIC VOID OsMemNodeInfo(const struct OsMemNodeHead *tmpNode, usedNode->header.ptr.prev, usedNode->header.magic, usedNode->header.sizeAndFlag); } else { freeNode = (struct OsMemFreeNodeHead *)tmpNode; - PRINTK("\n broken node head: %#x %#x %#x %#x, ", + PRINTK("\n broken node head: %#x %#x %#x %#x, %#x", freeNode->header.ptr.prev, freeNode->next, freeNode->prev, freeNode->header.magic, freeNode->header.sizeAndFlag); } @@ -1759,7 +1759,7 @@ STATIC VOID OsMemNodeInfo(const struct OsMemNodeHead *tmpNode, usedNode->header.ptr.prev, usedNode->header.magic, usedNode->header.sizeAndFlag); } else { freeNode = (struct OsMemFreeNodeHead *)preNode; - PRINTK("prev node head: %#x %#x %#x %#x, ", + PRINTK("prev node head: %#x %#x %#x %#x, %#x", freeNode->header.ptr.prev, freeNode->next, freeNode->prev, freeNode->header.magic, freeNode->header.sizeAndFlag); } diff --git a/kernel/base/misc/los_stackinfo.c b/kernel/base/misc/los_stackinfo.c index 5bac7160abb8ff6ccdb41a4a55bb37980c72e14e..f7ab26f3d2eac6cd85f13a6913fbd74b08f286fa 100644 --- a/kernel/base/misc/los_stackinfo.c +++ b/kernel/base/misc/los_stackinfo.c @@ -117,8 +117,10 @@ VOID OsExcStackInfoReg(const StackInfo *stackInfo, UINT32 stackNum) VOID OsStackInit(VOID *stacktop, UINT32 stacksize) { /* initialize the task stack, write magic num to stack top */ - (VOID)memset_s(stacktop, stacksize, (INT32)OS_STACK_INIT, stacksize); - *((UINTPTR *)stacktop) = OS_STACK_MAGIC_WORD; + errno_t ret = memset_s(stacktop, stacksize, (INT32)OS_STACK_INIT, stacksize); + if (ret == EOK) { + *((UINTPTR *)stacktop) = OS_STACK_MAGIC_WORD; + } } #ifdef LOSCFG_SHELL_CMD_DEBUG diff --git a/kernel/extended/hilog/los_hilog.c b/kernel/extended/hilog/los_hilog.c index 3537089239855e54ff1fadcc397d24eca1e6cd28..dd7c7c6f3238fd87346646de4931692a33f4936b 100644 --- a/kernel/extended/hilog/los_hilog.c +++ b/kernel/extended/hilog/los_hilog.c @@ -148,7 +148,7 @@ static int HiLogBufferCopy(unsigned char *dst, unsigned dstLen, const unsigned c static int HiLogReadRingBuffer(unsigned char *buffer, size_t bufLen) { - size_t retval; + int retval; size_t bufLeft = HILOG_BUFFER - g_hiLogDev.headOffset; if (bufLeft > bufLen) { retval = HiLogBufferCopy(buffer, bufLen, HiLogBufferHead(), bufLen); @@ -165,7 +165,7 @@ static int HiLogReadRingBuffer(unsigned char *buffer, size_t bufLen) static ssize_t HiLogRead(struct file *filep, char *buffer, size_t bufLen) { - size_t retval; + int retval; struct HiLogEntry header; (void)filep; @@ -209,7 +209,7 @@ out: g_hiLogDev.count = 0; } (VOID)LOS_MuxRelease(&g_hiLogDev.mtx); - return retval; + return (ssize_t)retval; } static int HiLogWriteRingBuffer(unsigned char *buffer, size_t bufLen) diff --git a/net/lwip-2.1/enhancement/src/api_shell.c b/net/lwip-2.1/enhancement/src/api_shell.c index 8c0c609f188be3d4d0b484d43948aba1cf95fa0b..5831bf56e462c67d7cd7c8b549ed4126601587b2 100644 --- a/net/lwip-2.1/enhancement/src/api_shell.c +++ b/net/lwip-2.1/enhancement/src/api_shell.c @@ -1337,10 +1337,10 @@ out: LWIP_STATIC void lwip_arp_usage(const char *cmd) { - PRINTK("Usage:"\ - "\n%s" - "\n%s [-i IF] -s IPADDR HWADDR"\ - "\n%s [-i IF] -d IPADDR\n", + PRINTK("Usage:" + "\n%s" + "\n%s [-i IF] -s IPADDR HWADDR" + "\n%s [-i IF] -d IPADDR\n", cmd, cmd, cmd); } diff --git a/testsuites/kernel/include/iCunit.h b/testsuites/kernel/include/iCunit.h index 6b7e0376c9a9e899a3a1e57272e58768b0476c7f..31d355e622063090460e82884d5b80dcfe6604c9 100644 --- a/testsuites/kernel/include/iCunit.h +++ b/testsuites/kernel/include/iCunit.h @@ -237,8 +237,6 @@ extern void ICunitSaveErr(iiUINT32 line, iiUINT32 retCode); #define ICUNIT_SUCCESS 0x00000000 -#if 1 - #define ICUNIT_TRACK_EQUAL(param, g_value, retcode) \ do { \ if ((param) != (g_value)) { \ @@ -414,114 +412,6 @@ extern void ICunitSaveErr(iiUINT32 line, iiUINT32 retCode); } \ } while (0) -#else - -#define ICUNIT_TRACK_EQUAL(param, g_value, retcode) \ - do { \ - if ((param) != (g_value)) { \ - g_iCunitErrLineNo = (g_iCunitErrLineNo == 0) ? __LINE__ : g_iCunitErrLineNo; \ - g_iCunitErrCode = (g_iCunitErrCode == 0) ? (iiUINT32)retcode : g_iCunitErrCode; \ - } \ - } while (0) - -#define ICUNIT_TRACK_NOT_EQUAL(param, g_value, retcode) \ - do { \ - if ((param) == (g_value)) { \ - g_iCunitErrLineNo = (g_iCunitErrLineNo == 0) ? __LINE__ : g_iCunitErrLineNo; \ - g_iCunitErrCode = (g_iCunitErrCode == 0) ? (iiUINT32)retcode : g_iCunitErrCode; \ - } \ - } while (0) - -#define ICUNIT_ASSERT_EQUAL_VOID(param, g_value, retcode) \ - do { \ - if ((param) != (g_value)) { \ - g_iCunitErrLineNo = (g_iCunitErrLineNo == 0) ? __LINE__ : g_iCunitErrLineNo; \ - g_iCunitErrCode = (g_iCunitErrCode == 0) ? (iiUINT32)retcode : g_iCunitErrCode; \ - return; \ - } \ - } while (0) - -#define ICUNIT_ASSERT_NOT_EQUAL_VOID(param, g_value, retcode) \ - do { \ - if ((param) == (g_value)) { \ - g_iCunitErrLineNo = (g_iCunitErrLineNo == 0) ? __LINE__ : g_iCunitErrLineNo; \ - g_iCunitErrCode = (g_iCunitErrCode == 0) ? (iiUINT32)retcode : g_iCunitErrCode; \ - return; \ - } \ - } while (0) -#define ICUNIT_ASSERT_EQUAL(param, g_value, retcode) \ - do { \ - if ((param) != (g_value)) { \ - g_iCunitErrLineNo = (g_iCunitErrLineNo == 0) ? __LINE__ : g_iCunitErrLineNo; \ - g_iCunitErrCode = (g_iCunitErrCode == 0) ? (iiUINT32)retcode : g_iCunitErrCode; \ - return 1; \ - } \ - } while (0) - -#define ICUNIT_ASSERT_NOT_EQUAL(param, g_value, retcode) \ - do { \ - if ((param) == (g_value)) { \ - g_iCunitErrLineNo = (g_iCunitErrLineNo == 0) ? __LINE__ : g_iCunitErrLineNo; \ - g_iCunitErrCode = (g_iCunitErrCode == 0) ? (iiUINT32)retcode : g_iCunitErrCode; \ - return 1; \ - } \ - } while (0) - -#define ICUNIT_ASSERT_STRING_EQUAL(str1, str2, retcode) \ - do { \ - if (strcmp(str1, str2) != 0) { \ - g_iCunitErrLineNo = (g_iCunitErrLineNo == 0) ? __LINE__ : g_iCunitErrLineNo; \ - g_iCunitErrCode = (g_iCunitErrCode == 0) ? (iiUINT32)retcode : g_iCunitErrCode; \ - return 1; \ - } \ - } while (0) - -#define ICUNIT_ASSERT_STRING_NOT_EQUAL(str1, str2, retcode) \ - do { \ - if (strcmp(str1, str2) == 0) { \ - g_iCunitErrLineNo = (g_iCunitErrLineNo == 0) ? __LINE__ : g_iCunitErrLineNo; \ - g_iCunitErrCode = (g_iCunitErrCode == 0) ? (iiUINT32)retcode : g_iCunitErrCode; \ - return 1; \ - } \ - } while (0) - -#define ICUNIT_GOTO_EQUAL(param, g_value, retcode, label) \ - do { \ - if ((param) != (g_value)) { \ - g_iCunitErrLineNo = (g_iCunitErrLineNo == 0) ? __LINE__ : g_iCunitErrLineNo; \ - g_iCunitErrCode = (g_iCunitErrCode == 0) ? (iiUINT32)retcode : g_iCunitErrCode; \ - goto label; \ - } \ - } while (0) - -#define ICUNIT_GOTO_NOT_EQUAL(param, g_value, retcode, label) \ - do { \ - if ((param) == (g_value)) { \ - g_iCunitErrLineNo = (g_iCunitErrLineNo == 0) ? __LINE__ : g_iCunitErrLineNo; \ - g_iCunitErrCode = (g_iCunitErrCode == 0) ? (iiUINT32)retcode : g_iCunitErrCode; \ - goto label; \ - } \ - } while (0) - -#define ICUNIT_GOTO_STRING_EQUAL(str1, str2, retcode, label) \ - do { \ - if (strcmp(str1, str2) != 0) { \ - g_iCunitErrLineNo = (g_iCunitErrLineNo == 0) ? __LINE__ : g_iCunitErrLineNo; \ - g_iCunitErrCode = (g_iCunitErrCode == 0) ? (iiUINT32)retcode : g_iCunitErrCode; \ - goto label; \ - } \ - } while (0) - -#define ICUNIT_GOTO_STRING_NOT_EQUAL(str1, str2, retcode, label) \ - do { \ - if (strcmp(str1, str2) == 0) { \ - g_iCunitErrLineNo = (g_iCunitErrLineNo == 0) ? __LINE__ : g_iCunitErrLineNo; \ - g_iCunitErrCode = (g_iCunitErrCode == 0) ? (iiUINT32)retcode : g_iCunitErrCode; \ - goto label; \ - } \ - } while (0) -#endif - #ifdef LOSCFG_KERNEL_SMP extern SPIN_LOCK_S g_testSuitSpin; #define TESTSUIT_LOCK(state) LOS_SpinLockSave(&g_testSuitSpin, &(state)) diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_timeslice_004.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_timeslice_004.c index d59e9882ef3fa943ff93f87d46b6c40855bf7593..cbe89f8582f2f32fc684e8fb87bec57a72be1c54 100644 --- a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_timeslice_004.c +++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_timeslice_004.c @@ -45,8 +45,6 @@ static void TaskF02(void const * argument) ICUNIT_GOTO_EQUAL(g_timesliceTestCount, 1, ret, EXIT); g_timesliceTestCount++; return; - -EXIT:; } static void SwtmrF01(UINT32 *arg) diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_022.c b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_022.c index 794af7dad704cce765a90b25f74dd43172a70bdc..686c18cde9f57185a4d114e44e4ac8a7dfa01de1 100644 --- a/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_022.c +++ b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_022.c @@ -117,7 +117,6 @@ EXIT: LOS_TaskDelete(g_testTaskID01); return LOS_OK; - return LOS_OK; } VOID ItLosEvent022(VOID) // IT_Layer_ModuleORFeature_No diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_032.c b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_032.c index cc6bd21fa7384efcf46c14739e97c1185fc9c810..9e6c9dfa03cfe76f62ca796bef49c52af2582240 100644 --- a/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_032.c +++ b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_032.c @@ -103,7 +103,6 @@ static UINT32 Testcase(void) PRINT_DEBUG("ret1= 0x%x,ret2 = 0x%x,ret3=0x%x\n", g_ret1, g_ret2, g_ret3); if ((g_ret1 == 0x11) && (g_ret2 == LOS_OK) && (g_ret3 == LOS_OK)) { // pend-post-del ///post-pend-del - } else if ((g_ret1 == 0x11) && (g_ret2 == LOS_OK) && (g_ret3 == LOS_OK)) { // del-pend-post//del-post-pend } else if ((g_ret1 == 0x11) && (g_ret2 == LOS_OK) && (g_ret3 == LOS_ERRNO_EVENT_SHOULD_NOT_DESTROY)) { // pend-delete-post } else if ((g_ret1 == 0xff) && (g_ret2 == LOS_OK) && (g_ret3 == LOS_OK)) { // post-del-pend diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_015.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_015.c index 3fb0e44139f6d3f9fa21aceb43bda9acbbb8e69e..0e437bf807d69a38309538b7d792cbc0d9e16bb7 100644 --- a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_015.c +++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_015.c @@ -56,8 +56,6 @@ static UINT32 Testcase(VOID) ret = LOS_QueueRead(queueID[index - 1], &buff2, sizeof(UINTPTR), 0); ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT); - ret = LOS_QueueCreate("Q1", 3, &queueID[index], 0, 8); // 3, Set the queue length; 8, Set the node size of the queue. - ret = LOS_QueueCreate("Q1", 3, &queueID[index], 0, 8); // 3, Set the queue length; 8, Set the node size of the queue. ICUNIT_GOTO_NOT_EQUAL(ret, LOS_OK, ret, EXIT); EXIT: diff --git a/testsuites/kernel/sample/kernel_extend/cpup/It_extend_cpup.c b/testsuites/kernel/sample/kernel_extend/cpup/It_extend_cpup.c index fc348ff56b5378e584dd47155120e1e309faf6ef..ec095e56869ed0831ab56b7d67961923c088661d 100644 --- a/testsuites/kernel/sample/kernel_extend/cpup/It_extend_cpup.c +++ b/testsuites/kernel/sample/kernel_extend/cpup/It_extend_cpup.c @@ -46,7 +46,7 @@ UINT32 TestGetSingleHwiCpup(UINT32 hwi, UINT32 mode) { UINT32 size; UINT32 tempHwi; - if (hwi < 0 || hwi > OS_HWI_MAX_NUM) { + if (hwi > OS_HWI_MAX_NUM) { return -1; } diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_023.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_023.c index 1f024163ab733c5d2aedc815dcb30c69b820e32d..89caf553a80560c6e663128dedc9efd644c1afcd 100644 --- a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_023.c +++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_023.c @@ -51,7 +51,6 @@ static VOID *PthreadF01(void *argument) pthread_cleanup_push(PthreadCleanF01, (void *)8); // 8, here set value. return (void *)8; // 8, here set value about the return status. - pthread_cleanup_pop(0) } static UINT32 Testcase(VOID) @@ -85,4 +84,4 @@ VOID ItPosixPthread023(VOID) // IT_Layer_ModuleORFeature_No #if __cplusplus } #endif /* __cpluscplus */ -#endif /* __cpluscplus */ \ No newline at end of file +#endif /* __cpluscplus */ diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_069.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_069.c index f2c258ba99b1a6f4f55411d92f734004ff5bd83e..457c4600e2a908b209ced10316131e55ca26e616 100644 --- a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_069.c +++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_069.c @@ -51,13 +51,17 @@ static UINT32 Testcase(VOID) ICUNIT_ASSERT_EQUAL(rc, 0, rc); rc = pthread_cond_init(&cond2, NULL); - ICUNIT_ASSERT_EQUAL(rc, 0, rc); + ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT); rc = pthread_cond_destroy(&cond1); - ICUNIT_ASSERT_EQUAL(rc, ENOERR, rc); + ICUNIT_GOTO_EQUAL(rc, ENOERR, rc, EXIT); rc = pthread_cond_destroy(&cond2); - ICUNIT_ASSERT_EQUAL(rc, ENOERR, rc); + ICUNIT_GOTO_EQUAL(rc, ENOERR, rc, EXIT); + return PTHREAD_NO_ERROR; +EXIT: + (void)pthread_cond_destroy(&cond1); + (void)pthread_cond_destroy(&cond2); } VOID ItPosixPthread069(VOID) // IT_Layer_ModuleORFeature_No @@ -69,4 +73,4 @@ VOID ItPosixPthread069(VOID) // IT_Layer_ModuleORFeature_No #if __cplusplus } #endif /* __cpluscplus */ -#endif /* __cpluscplus */ \ No newline at end of file +#endif /* __cpluscplus */ diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_101.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_101.c index d41b131846349445d6acf39b220a87b64bb5aca6..0d04ba1737c93bab60d7b7c278d46eae47a94762 100644 --- a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_101.c +++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_101.c @@ -48,8 +48,7 @@ static VOID *PthreadF01(void *argument) ret = pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldstate); ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT); ICUNIT_GOTO_EQUAL(oldstate, PTHREAD_CANCEL_DEFERRED, oldstate, EXIT); - LOS_TaskDelay(2); // 2, delay for Timing control. - LOS_TaskDelay(2); // 2, delay for Timing control. + LOS_TaskDelay(4); // 4, delay for Timing control. EXIT: return (void *)9; // 9, here set value about the return status. diff --git a/testsuites/unittest/basic/dynload/smoke/dynload_test_002.cpp b/testsuites/unittest/basic/dynload/smoke/dynload_test_002.cpp index 0c2e5f5acef3ed7021df07026708c1c0017246e3..7a175f77f80cf2ea4e834ec66022e3cbc5d34dc6 100644 --- a/testsuites/unittest/basic/dynload/smoke/dynload_test_002.cpp +++ b/testsuites/unittest/basic/dynload/smoke/dynload_test_002.cpp @@ -56,8 +56,8 @@ static int Testcase(void) ICUNIT_ASSERT_NOT_EQUAL(handle, NULL, handle); func = (int (*)(int))dlsym(handle, SYMBOL_TO_FIND); - ICUNIT_ASSERT_NOT_EQUAL(func, NULL, func); - ICUNIT_ASSERT_EQUAL(func, SYMBOL_TO_MATCH, func); + ICUNIT_GOTO_NOT_EQUAL(func, NULL, func, EXIT); + ICUNIT_GOTO_EQUAL(func, SYMBOL_TO_MATCH, func, EXIT); ret = dlclose(handle); ICUNIT_ASSERT_EQUAL(ret, 0, ret); @@ -66,12 +66,16 @@ static int Testcase(void) ICUNIT_ASSERT_NOT_EQUAL(handle, NULL, handle); func = (int (*)(int))dlsym(handle, SYMBOL_TO_FIND); - ICUNIT_ASSERT_NOT_EQUAL(func, NULL, func); + ICUNIT_GOTO_NOT_EQUAL(func, NULL, func, EXIT); ret = dlclose(handle); ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; + +EXIT: + dlclose(handle); + return 0; } void ItTestDynload002(void) diff --git a/testsuites/unittest/basic/mem/shm/full/it_test_mem_100.cpp b/testsuites/unittest/basic/mem/shm/full/it_test_mem_100.cpp index 05e1a59f518d9f30e9e1cd2f8aa991a3a4b53ea0..addcc3d673887f793b5b0109da71181fb1453222 100644 --- a/testsuites/unittest/basic/mem/shm/full/it_test_mem_100.cpp +++ b/testsuites/unittest/basic/mem/shm/full/it_test_mem_100.cpp @@ -42,6 +42,8 @@ static int TestCase(void) wchar_t *p, *pnew; pnew = (wchar_t*)malloc(sizeof(wchar_t) * (wcslen(res) + wcslen(res1))); + ICUNIT_ASSERT_NOT_EQUAL(pnew, NULL, pnew); + p = wmempcpy(pnew, res, wcslen(res)); wmempcpy(p, res1, wcslen(res1)); flag = wmemcmp(pnew, res2, wcslen(res)); 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 ab659ce915f24bc1a447a2db4cfb2473773cf08c..ba98058f5395ff52beadce6ad3b9b31555728966 100644 --- a/testsuites/unittest/basic/mem/shm/full/shm_test_013.cpp +++ b/testsuites/unittest/basic/mem/shm/full/shm_test_013.cpp @@ -44,21 +44,27 @@ static int testcase(void) ICUNIT_ASSERT_NOT_EQUAL(shmfd, -1, shmfd); writebuf = (char*)malloc(pageSize); - ICUNIT_ASSERT_NOT_EQUAL(writebuf, NULL, writebuf); + ICUNIT_ASSERT_NOT_EQUAL(writebuf, NULL, writebuf); readbuf = (char*)malloc(pageSize); - ICUNIT_ASSERT_NOT_EQUAL(readbuf, NULL, readbuf); + ICUNIT_GOTO_NOT_EQUAL(readbuf, NULL, readbuf, EXIT); (void)memset_s(writebuf, pageSize, 0xf, pageSize); count = write(shmfd, writebuf, pageSize); - ICUNIT_ASSERT_EQUAL(count, pageSize, count); + ICUNIT_GOTO_EQUAL(count, pageSize, count, EXIT); ret = lseek(shmfd, 0, SEEK_SET); - ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT); count = read(shmfd, readbuf, pageSize); - ICUNIT_ASSERT_EQUAL(count, pageSize, count); - free(readbuf); - free(writebuf); + ICUNIT_GOTO_EQUAL(count, pageSize, count, EXIT); + +EXIT: + if (readbuf != NULL) { + free(readbuf); + } + if (writebuf != NULL) { + free(writebuf); + } close(shmfd); ret = shm_unlink("test_1"); return 0; diff --git a/testsuites/unittest/basic/mem/vm/mem_vm_test.cpp b/testsuites/unittest/basic/mem/vm/mem_vm_test.cpp index 61e9f8fbda67f24787bc72119692af9985dcb817..982dbff34f7f15653f878ab72aa052aca2f59bbe 100644 --- a/testsuites/unittest/basic/mem/vm/mem_vm_test.cpp +++ b/testsuites/unittest/basic/mem/vm/mem_vm_test.cpp @@ -51,37 +51,6 @@ HWTEST_F(MemVmTest, ItTestMmap001, TestSize.Level0) { ItTestMmap001(); } -#if 0 // need tmpfs -/* * - * @tc.name: it_test_mmap_002 - * @tc.desc: function for MemVmTest - * @tc.type: FUNC - */ -HWTEST_F(MemVmTest, ItTestMmap002, TestSize.Level0) -{ - ItTestMmap002(); -} - -/* * - * @tc.name: it_test_mmap_003 - * @tc.desc: function for MemVmTest - * @tc.type: FUNC - */ -HWTEST_F(MemVmTest, ItTestMmap003, TestSize.Level0) -{ - ItTestMmap003(); -} - -/* * - * @tc.name: it_test_mmap_004 - * @tc.desc: function for MemVmTest - * @tc.type: FUNC - */ -HWTEST_F(MemVmTest, ItTestMmap004, TestSize.Level0) -{ - ItTestMmap004(); -} -#endif /* * * @tc.name: it_test_mmap_005 diff --git a/testsuites/unittest/basic/mem/vm/smoke/mmap_test_002.cpp b/testsuites/unittest/basic/mem/vm/smoke/mmap_test_002.cpp index ed5c4a4d29fad7e74b07e7a0e2286b5d56d75a04..8731e27ef80866d12d80ed870bf8f2ae25593788 100644 --- a/testsuites/unittest/basic/mem/vm/smoke/mmap_test_002.cpp +++ b/testsuites/unittest/basic/mem/vm/smoke/mmap_test_002.cpp @@ -76,8 +76,10 @@ static int Testcase(void) (void)memset_s(buf, pageSize, 0xf, pageSize); count = write(shmfd, buf, pageSize); - ICUNIT_ASSERT_EQUAL(count, pageSize, count); - + if (count != pageSize) { + free(buf); + ICUNIT_ASSERT_EQUAL(count, pageSize, count); + } free(buf); /* Simple MAP_ANONYMOUS */ diff --git a/testsuites/unittest/extended/ipc/ipc_test.cpp b/testsuites/unittest/extended/ipc/ipc_test.cpp index 1b8fa8bbeca880e0da382192f038dc332aed0bf8..4fb45462f653ee0963610199e053751e4ceca0af 100644 --- a/testsuites/unittest/extended/ipc/ipc_test.cpp +++ b/testsuites/unittest/extended/ipc/ipc_test.cpp @@ -40,30 +40,4 @@ public: static void SetUpTestCase(void) {} static void TearDownTestCase(void) {} }; - -#if defined(LOSCFG_USER_TEST_FULL) -/* * - * @tc.name: IPC_TEST_MKFIFOAT_001 - * @tc.desc: function for IoTest:mkfifoat-normal test - * @tc.type: FUNC - */ -#if 0 -HWTEST_F(IoTest, IPC_TEST_MKFIFOAT_001, TestSize.Level0) -{ - IPC_TEST_MKFIFOAT_001(); -} -#endif - -/* * - * @tc.name: IPC_TEST_MKFIFOAT_002 - * @tc.desc: function for IoTest:mkfifoat-innormal test - * @tc.type: FUNC - */ -#if 0 -HWTEST_F(IoTest, IPC_TEST_MKFIFOAT_002, TestSize.Level0) -{ - IPC_TEST_MKFIFOAT_002(); -} -#endif -#endif } // namespace OHOS diff --git a/testsuites/unittest/extended/signal/smoke/mkfifo_test_001.cpp b/testsuites/unittest/extended/signal/smoke/mkfifo_test_001.cpp index a0832bb5372d9989a8608cd3b78e41f90201abff..fb4c3d833860bc3d16be4587720afb911a229043 100644 --- a/testsuites/unittest/extended/signal/smoke/mkfifo_test_001.cpp +++ b/testsuites/unittest/extended/signal/smoke/mkfifo_test_001.cpp @@ -56,11 +56,17 @@ static int TestMkfifo() return -1; } else if (pid == 0) { fd = open("/dev/fifo", O_WRONLY); + if (fd < 0) { + return -1; + } write(fd, sentence, sizeof(sentence) + 1); close(fd); exit(0); } else { fd = open("/dev/fifo", O_RDONLY); + if (fd < 0) { + return -1; + } read(fd, buffer, sizeof(buffer)); printf("Receive data: %s\n", buffer); close(fd); diff --git a/testsuites/unittest/libc/io/full/It_stdio_fwprintf_001.cpp b/testsuites/unittest/libc/io/full/It_stdio_fwprintf_001.cpp index 6cda97adca83a85b97d71926e68e93d0bdd9a1c8..1bf571149ac3808fa09ac0b40e09557ead7378a8 100644 --- a/testsuites/unittest/libc/io/full/It_stdio_fwprintf_001.cpp +++ b/testsuites/unittest/libc/io/full/It_stdio_fwprintf_001.cpp @@ -60,6 +60,8 @@ static UINT32 Testcase(VOID) fclose(testFile); testFile = fopen(pathname, "r"); + ICUNIT_GOTO_NOT_EQUAL(testFile, NULL, testFile, EXIT); + p = fgetws(tarStr, 16, testFile); // 16, read size,total write and '\0' nRet = wcscmp(L"hello world 666", tarStr); ICUNIT_GOTO_EQUAL(nRet, 0, nRet, EXIT); 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 f493a15c20b7980e59d5f0c52fb23593601b6214..151a7b4b9027c57b6b31dba03590407b41da2a6a 100644 --- a/testsuites/unittest/libc/io/full/It_stdio_hasmntopt_001.cpp +++ b/testsuites/unittest/libc/io/full/It_stdio_hasmntopt_001.cpp @@ -55,6 +55,10 @@ static UINT32 testcase(VOID) } mnt_new = (struct mntent *)malloc(sizeof(struct mntent)); + if (mnt_new == NULL) { + (VOID)RecoveryFileEnv(pathList, 1); + return LOS_NOK; + } mnt_new->mnt_fsname = "UUID=c4992556-a86e-45e8-ba5f-190b16a9073x"; mnt_new->mnt_dir = "/usr1"; mnt_new->mnt_type = "ext3"; diff --git a/testsuites/unittest/libc/io/full/It_stdio_putwc_001.cpp b/testsuites/unittest/libc/io/full/It_stdio_putwc_001.cpp index 6c122743885a4b7b0959095b1746bf20a018b453..a36673857e851f8bdeb9a37e8c02c3b8b76acb88 100644 --- a/testsuites/unittest/libc/io/full/It_stdio_putwc_001.cpp +++ b/testsuites/unittest/libc/io/full/It_stdio_putwc_001.cpp @@ -55,6 +55,8 @@ static UINT32 Testcase(VOID) fclose(putwcFile); putwcFile = fopen(pathname, "r"); + ICUNIT_GOTO_NOT_EQUAL(putwcFile, NULL, putwcFile, EXIT); + tarWc = getwc(putwcFile); ICUNIT_GOTO_EQUAL(tarWc, L'H', tarWc, EXIT); diff --git a/testsuites/unittest/libc/posix/mqueue/full/It_posix_queue_134.cpp b/testsuites/unittest/libc/posix/mqueue/full/It_posix_queue_134.cpp index bc147b0caf78dc02e094632d40f5fb6ae73c639e..1293dce174ec730844da394072e01631154c73c1 100644 --- a/testsuites/unittest/libc/posix/mqueue/full/It_posix_queue_134.cpp +++ b/testsuites/unittest/libc/posix/mqueue/full/It_posix_queue_134.cpp @@ -44,8 +44,6 @@ static UINT32 Testcase(VOID) ICUNIT_GOTO_EQUAL(ret, MQUEUE_IS_ERROR, ret, EXIT1); - ICUNIT_GOTO_EQUAL(ret, MQUEUE_IS_ERROR, ret, EXIT1); - ret = mq_close(mqueue); ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT1); diff --git a/testsuites/unittest/libc/posix/pthread/full/It_posix_pthread_044.cpp b/testsuites/unittest/libc/posix/pthread/full/It_posix_pthread_044.cpp index 9c8c79d9d33e01016be1cfe2cc9dd45b2218fe4b..35e76fe09eeaacd301c19ee80f418a0e0da5abe2 100644 --- a/testsuites/unittest/libc/posix/pthread/full/It_posix_pthread_044.cpp +++ b/testsuites/unittest/libc/posix/pthread/full/It_posix_pthread_044.cpp @@ -43,7 +43,6 @@ static VOID *pthread_f02(void *argument) ret = pthread_getschedparam(pthread_self(), &policy, ¶m); ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT); - ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT); ICUNIT_GOTO_EQUAL(policy, SCHED_RR, policy, EXIT); // ICUNIT_GOTO_EQUAL(param.sched_priority, 3, param.sched_priority, EXIT); @@ -63,7 +62,6 @@ static VOID *pthread_f01(void *argument) ret = pthread_getschedparam(pthread_self(), &policy, ¶m); ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT); - ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT); ICUNIT_GOTO_EQUAL(policy, SCHED_RR, policy, EXIT); // ICUNIT_GOTO_EQUAL(param.sched_priority, 4, param.sched_priority, EXIT); diff --git a/testsuites/unittest/libc/sys/smoke/sys_test_007.cpp b/testsuites/unittest/libc/sys/smoke/sys_test_007.cpp index 46a2e04d3ae9e03ef42451589e7bccb3fddbf4ee..cc14a15685e79b36f9441d33a409866c539b44ca 100644 --- a/testsuites/unittest/libc/sys/smoke/sys_test_007.cpp +++ b/testsuites/unittest/libc/sys/smoke/sys_test_007.cpp @@ -43,7 +43,7 @@ static UINT32 TestCase(VOID) ICUNIT_GOTO_NOT_EQUAL(p, NULL, p, EXIT); x = drand48(); - printf("x= %d\n", x); + printf("x= %lf\n", x); return 0; EXIT: diff --git a/testsuites/unittest/libc/sys/smoke/sys_test_030.cpp b/testsuites/unittest/libc/sys/smoke/sys_test_030.cpp index 59384fa4350f2f536d89f2d213c587c1690ce82c..8e3bc49edfaf9b3b7448ad5e07347c9bff0c2dad 100644 --- a/testsuites/unittest/libc/sys/smoke/sys_test_030.cpp +++ b/testsuites/unittest/libc/sys/smoke/sys_test_030.cpp @@ -42,18 +42,6 @@ static void sig_alarm(int signum) static UINT32 TestCase(VOID) { -#if 0 - int alarm_time = 1; - int ret; - - signal(SIGALRM, sig_alarm); - alarm(alarm_time); - ret = sigsetjmp(jmp_env, 1); - if (ret) { - ICUNIT_ASSERT_EQUAL(ret, val, ret); - } - sleep(3); -#endif return 0; } diff --git a/testsuites/unittest/libc/util/smoke/util_test_003.cpp b/testsuites/unittest/libc/util/smoke/util_test_003.cpp index 6ebea016c01ca3bffec5c6f956c237825afc1a61..867aa173cd193921dfc6ee528022ab2bedb7c6f2 100644 --- a/testsuites/unittest/libc/util/smoke/util_test_003.cpp +++ b/testsuites/unittest/libc/util/smoke/util_test_003.cpp @@ -48,6 +48,9 @@ static UINT32 TestCase(VOID) NULL }; CHAR *buf = (char *)malloc(TEST_BUF_SIZE); + if (buf == NULL) { + return -1; + } CHAR *a = TEST_STR; CHAR *value = NULL; CHAR *subopts = NULL; diff --git a/testsuites/unittest/libc/util/smoke/util_test_007.cpp b/testsuites/unittest/libc/util/smoke/util_test_007.cpp index cacdae8db105789c70350cc7cc5c0799ce33a143..80dc8212453916315ebe70d798d7a69b3af324e3 100644 --- a/testsuites/unittest/libc/util/smoke/util_test_007.cpp +++ b/testsuites/unittest/libc/util/smoke/util_test_007.cpp @@ -87,11 +87,13 @@ static UINT32 TestCase(VOID) ptr = (int *)Xmalloc(sizeof(int)); *ptr = rand() & 0xff; val = tsearch((void *)ptr, &g_root, Compare); - if (val == NULL) + if (val == NULL) { exit(EXIT_FAILURE); - else if ((*(int **)val) != ptr) + } else if ((*(int **)val) != ptr) { free(ptr); + } } + twalk(g_root, Action); tdestroy(g_root, free); diff --git a/testsuites/unittest/net/socket/smoke/net_socket_test_003.cpp b/testsuites/unittest/net/socket/smoke/net_socket_test_003.cpp index 6dbcab642be2df654e14fadd1fcc0c82d552d286..925002140819471b28721677d8d594d9276fcb0c 100644 --- a/testsuites/unittest/net/socket/smoke/net_socket_test_003.cpp +++ b/testsuites/unittest/net/socket/smoke/net_socket_test_003.cpp @@ -83,7 +83,7 @@ static int SampleTcpServer() ICUNIT_ASSERT_NOT_EQUAL(sfd, -1, sfd); /* send */ - ret = memset_s(gBuf, BUF_SIZE - 1, 0, BUF_SIZE - 1); + ret = memset_s(gBuf, BUF_SIZE + 1, 0, BUF_SIZE + 1); ICUNIT_ASSERT_EQUAL(ret, 0, ret); gBuf[BUF_SIZE - 1] = '\0'; ret = strcpy_s(gBuf, BUF_SIZE - 1, SRV_MSG); @@ -94,7 +94,7 @@ static int SampleTcpServer() ICUNIT_ASSERT_EQUAL(ret, strlen(SRV_MSG), ret); /* recv */ - ret = memset_s(gBuf, BUF_SIZE - 1, 0, BUF_SIZE - 1); + ret = memset_s(gBuf, BUF_SIZE + 1, 0, BUF_SIZE + 1); ICUNIT_ASSERT_EQUAL(ret, 0, ret); gBuf[BUF_SIZE - 1] = '\0'; ret = recv(sfd, gBuf, sizeof(gBuf), 0); @@ -107,7 +107,7 @@ static int SampleTcpServer() clnAddr.sin_family = AF_INET; clnAddr.sin_addr.s_addr = inet_addr(PEER_IP); clnAddr.sin_port = htons(PEER_PORT); - ret = memset_s(gBuf, BUF_SIZE - 1, 0, BUF_SIZE - 1); + ret = memset_s(gBuf, BUF_SIZE + 1, 0, BUF_SIZE + 1); ICUNIT_ASSERT_EQUAL(ret, 0, ret); gBuf[BUF_SIZE - 1] = '\0'; ret = strcpy_s(gBuf, BUF_SIZE - 1, SRV_MSG); @@ -128,7 +128,7 @@ static int SampleTcpServer() Wait(); /* recvmsg */ - ret = memset_s(gBuf, BUF_SIZE - 1, 0, BUF_SIZE - 1); + ret = memset_s(gBuf, BUF_SIZE + 1, 0, BUF_SIZE + 1); ICUNIT_ASSERT_EQUAL(ret, 0, ret); gBuf[BUF_SIZE - 1] = '\0'; ret = memset_s(&msg, sizeof(msg), 0, sizeof(msg)); @@ -196,7 +196,7 @@ static int SampleTcpClient() inet_addr(STACK_IP), ((struct sockaddr_in*)&addr)->sin_addr.s_addr); /* send */ - ret = memset_s(gBuf, BUF_SIZE - 1, 0, BUF_SIZE - 1); + ret = memset_s(gBuf, BUF_SIZE + 1, 0, BUF_SIZE + 1); ICUNIT_ASSERT_EQUAL(ret, 0, ret); gBuf[BUF_SIZE - 1] = '\0'; ret = strcpy_s(gBuf, BUF_SIZE - 1, CLI_MSG); @@ -207,7 +207,7 @@ static int SampleTcpClient() ICUNIT_ASSERT_EQUAL(ret, strlen(CLI_MSG), ret); /* recv */ - ret = memset_s(gBuf, BUF_SIZE - 1, 0, BUF_SIZE - 1); + ret = memset_s(gBuf, BUF_SIZE + 1, 0, BUF_SIZE + 1); ICUNIT_ASSERT_EQUAL(ret, 0, ret); gBuf[BUF_SIZE - 1] = '\0'; ret = recv(sfd, gBuf, sizeof(gBuf), 0); @@ -220,7 +220,7 @@ static int SampleTcpClient() clnAddr.sin_family = AF_INET; clnAddr.sin_addr.s_addr = inet_addr(PEER_IP); clnAddr.sin_port = htons(PEER_PORT); - ret = memset_s(gBuf, BUF_SIZE - 1, 0, BUF_SIZE - 1); + ret = memset_s(gBuf, BUF_SIZE + 1, 0, BUF_SIZE + 1); ICUNIT_ASSERT_EQUAL(ret, 0, ret); gBuf[BUF_SIZE - 1] = '\0'; ret = strcpy_s(gBuf, BUF_SIZE - 1, CLI_MSG); @@ -241,7 +241,7 @@ static int SampleTcpClient() Wait(); /* recvmsg */ - ret = memset_s(gBuf, BUF_SIZE - 1, 0, BUF_SIZE - 1); + ret = memset_s(gBuf, BUF_SIZE + 1, 0, BUF_SIZE + 1); ICUNIT_ASSERT_EQUAL(ret, 0, ret); gBuf[BUF_SIZE - 1] = '\0'; ret = memset_s(&msg, sizeof(msg), 0, sizeof(msg)); diff --git a/testsuites/unittest/net/socket/smoke/net_socket_test_007.cpp b/testsuites/unittest/net/socket/smoke/net_socket_test_007.cpp index f3418093b412e1e6168fd14771e460831ba2f767..94bc166b46286b0bd2a846a7996f26edf20259dd 100644 --- a/testsuites/unittest/net/socket/smoke/net_socket_test_007.cpp +++ b/testsuites/unittest/net/socket/smoke/net_socket_test_007.cpp @@ -139,13 +139,17 @@ static int TcpTest() } else { printf("malloc 20M success\n"); ret = memset_s(buf, bufSiz, 0, bufSiz); - ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT); ret = send(lsfd, buf, bufSiz, 0); printf("send ret = %d, errno :%d\n", ret, errno); - ICUNIT_ASSERT_EQUAL(ret, -1, ret); + ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT); } -#endif +EXIT: + if (buf != NULL) { + free(buf); + } +#endif close(lsfd); return 0; } diff --git a/testsuites/unittest/process/basic/process/full/process_test_066.cpp b/testsuites/unittest/process/basic/process/full/process_test_066.cpp index a29be892a0996f683ad7cf5d7d5612b99c0a1d8e..f12bd0d3962c83f3fd3798e5722c871311e63f22 100644 --- a/testsuites/unittest/process/basic/process/full/process_test_066.cpp +++ b/testsuites/unittest/process/basic/process/full/process_test_066.cpp @@ -149,6 +149,9 @@ static int TestSpawnAttr(short flag) ICUNIT_GOTO_EQUAL(status, 0, status, EXIT); fd = open("/storage/testspawnattr.txt", O_RDWR | O_CREAT, 0644); // 0644, open config + if (fd < 0) { + goto EXIT; + } ret = read(fd, temp, NUMMAX); ICUNIT_GOTO_EQUAL(ret, NUMMAX, ret, EXIT1); diff --git a/testsuites/unittest/process/basic/process/smoke/process_test_046.cpp b/testsuites/unittest/process/basic/process/smoke/process_test_046.cpp index 0232fff35e8d80df05a8486e7f8b2e7950de323d..a6f849a1808a201f6e4b7319831802f3825929dd 100644 --- a/testsuites/unittest/process/basic/process/smoke/process_test_046.cpp +++ b/testsuites/unittest/process/basic/process/smoke/process_test_046.cpp @@ -51,7 +51,6 @@ static int Testcase(void) CPU_SET(1, &cpuset); /* cpu1 unsupported operation */ ret = sched_setaffinity(getpid(), sizeof(cpu_set_t), &cpuset); ICUNIT_GOTO_EQUAL(ret, -1, ret, ERROR_OUT); - CPU_ZERO(&cpuset); CPU_ZERO(&cpuset); CPU_SET(0, &cpuset); /* cpu0 */ diff --git a/testsuites/unittest/security/vid/smoke/vid_test_001.cpp b/testsuites/unittest/security/vid/smoke/vid_test_001.cpp index d2dc6be011fe4a167b177467c789e51d715dac3e..631dcf283277e97021f4eb5cdf80ef6cb8629fa2 100644 --- a/testsuites/unittest/security/vid/smoke/vid_test_001.cpp +++ b/testsuites/unittest/security/vid/smoke/vid_test_001.cpp @@ -55,7 +55,14 @@ static void ChildFunc() ent.sigev_signo = SIGUSR1; tid2 = (timer_t *)malloc(sizeof(UINTPTR) * 1024); + if (tid2 == NULL) { + return; + } ret1 = (int *)malloc(sizeof(int) * 1024); + if (ret1 == NULL) { + free(tid2); + return; + } (void)memset_s(tid2, sizeof(char *) * 1024, 0, sizeof(char *) * 1024); (void)memset_s(ret1, sizeof(int) * 1024, 0xff, sizeof(int) * 1024); while (i < 1024) {