提交 96b2d557 编写于 作者: Y yinjiaming

fix: 内核告警修复

【背景】
经代码扫描工具检测,内核代码中存在
可以修复的告警

【修改方案】
1.将单语句的if, while等加上括号
2.将C语言风格的类型转换变为C++风格

【影响】
对现有的产品编译不会有影响。
Signed-off-by: Nyinjiaming <yinjiaming@huawei.com>
Change-Id: I7d4a04a8904abb3c33e843049bf15f4386d3efd8
上级 71e51d88
......@@ -62,8 +62,9 @@ static struct ProcDirEntry g_procRootDirEntry = {
int ProcMatch(unsigned int len, const char *name, struct ProcDirEntry *pn)
{
if (len != pn->nameLen)
if (len != pn->nameLen) {
return 0;
}
return !strncmp(name, pn->name, len);
}
......@@ -387,8 +388,9 @@ static void FreeProcEntry(struct ProcDirEntry *entry)
void ProcFreeEntry(struct ProcDirEntry *pn)
{
if (atomic_dec_and_test(&pn->count))
if (atomic_dec_and_test(&pn->count)) {
FreeProcEntry(pn);
}
}
static void RemoveProcEntryTravalsal(struct ProcDirEntry *pn)
......
......@@ -344,7 +344,7 @@ int osShellCmdMount(int argc, const char **argv)
filessystemtype = (argc >= 4) ? (char *)argv[3] : NULL; /* 4: specify fs type, 3: fs type */
mountfalgs = (argc >= 5) ? get_mountflags((const char *)argv[4]) : 0; /* 4: usr option */
data = (argc >= 6) ? (char *)argv[5] : NULL; /* 5: usr option data */
data = (argc >= 6) ? (char *)argv[5] : NULL; /* 5: usr option data, 6: six args needed for data */
if (strcmp(argv[1], "0") == 0) {
ret = mount((const char *)NULL, fullpath, filessystemtype, mountfalgs, data);
......@@ -384,7 +384,7 @@ int osShellCmdMount(int argc, const char **argv)
}
mountfalgs = (argc >= 4) ? get_mountflags((const char *)argv[3]) : 0; /* 3: usr option */
data = (argc >= 5) ? (char *)argv[4] : NULL; /* 4: usr option data */
data = (argc >= 5) ? (char *)argv[4] : NULL; /* 4: usr option data, 5: number of args needed for data */
if (strcmp(argv[0], "0") == 0) {
ret = mount((const char *)NULL, fullpath, argv[2], mountfalgs, data);
......
......@@ -404,7 +404,7 @@ STATIC VOID EchoToTerminal(CONSOLE_CB *consoleCB, struct file *filep, const stru
{
if (consoleCB->consoleTermios.c_lflag & ECHO) {
if (ch == '\b') {
(VOID)fops->write(filep, "\b \b", 3);
(VOID)fops->write(filep, "\b \b", 3); // 3: length of "\b \b"
} else {
(VOID)fops->write(filep, &ch, EACH_CHAR);
}
......
......@@ -34,8 +34,8 @@
#if LWIP_PERF
#define PERF_START do {/* something to do */} while (0)
#define PERF_STOP(x) do {/* something to do */} while (0)
#define PERF_START do {} while (0) /* something to do */
#define PERF_STOP(x) do {} while (0) /* something to do */
#endif
......
......@@ -48,8 +48,9 @@ static VOID SwtmrF01(VOID)
g_eventMask = g_eventMask | (1 << g_testCount);
if (g_testCount > 17) // g_testCount > 17, do noting return
if (g_testCount > 17) { // g_testCount > 17, do noting return
return;
}
ret = LOS_EventWrite(&g_event, g_eventMask);
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
......
......@@ -104,9 +104,9 @@ static UINT32 Testcase(VOID)
TestAssertBusyTaskDelay(100, 3); // 100, Set the timeout of runtime; 3, test running count
ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert that g_testCount is equal to
if ((g_ret1 + g_ret2 == 0xff) && (TestAbs(g_ret1, g_ret2) == 0xff))
if ((g_ret1 + g_ret2 == 0xff) && (TestAbs(g_ret1, g_ret2) == 0xff)) {
ICUNIT_GOTO_EQUAL(1, 1, g_ret1, EXIT);
else {
} else {
ICUNIT_GOTO_EQUAL(1, 0, g_ret1, EXIT);
}
PRINT_DEBUG("ret1=0x%x,ret2=0x%x\n", g_ret1, g_ret2);
......
......@@ -105,8 +105,9 @@ static UINT32 Testcase(VOID)
ret = pthread_create(&newTh3, NULL, PthreadF03, NULL);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
while (g_testCount < 6) // 6, wait until g_testCount is equal to 6.
while (g_testCount < 6) { // 6, wait until g_testCount is equal to 6.
sleep(1);
}
ICUNIT_ASSERT_EQUAL(g_testCount, 6, g_testCount); // 6, here assert the result.
......
......@@ -75,8 +75,9 @@ static UINT32 Testcase(VOID)
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
}
while (g_startNum < THREAD_NUM)
while (g_startNum < THREAD_NUM) {
usleep(100); // 100, delay for Timing control.
}
/*
* Acquire the mutex to make sure that all waiters are currently
......
......@@ -80,8 +80,9 @@ static UINT32 Testcase(VOID)
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
}
while (g_startNum < THREAD_NUM)
while (g_startNum < THREAD_NUM) {
usleep(100); // 100, delay for Timing control.
}
/*
* Acquire the mutex to make sure that all waiters are currently
......
......@@ -87,8 +87,9 @@ static UINT32 Testcase(VOID)
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
}
while (g_startNum < THREAD_NUM)
while (g_startNum < THREAD_NUM) {
usleep(100); // 100, delay for Timing control.
}
/*
* Acquire the mutex to make sure that all waiters are currently
......
......@@ -76,8 +76,9 @@ static UINT32 Testcase(VOID)
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
}
while (g_startNum < THREAD_NUM)
while (g_startNum < THREAD_NUM) {
usleep(100); // 100, delay for Timing control.
}
/*
* Acquire the mutex to make sure that all waiters are currently
......
......@@ -79,8 +79,9 @@ static UINT32 Testcase(VOID)
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
}
while (g_startNum < THREAD_NUM)
while (g_startNum < THREAD_NUM) {
usleep(100); // 100, delay for Timing control.
}
/*
* Acquire the mutex to make sure that all waiters are currently
......
......@@ -75,8 +75,9 @@ static UINT32 Testcase(VOID)
rc = pthread_create(&thread1, NULL, PthreadF01, NULL);
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
while (!g_t1Start) /* wait for thread1 started */
while (!g_t1Start) { /* wait for thread1 started */
usleep(100); // 100, delay for Timing control.
}
/* acquire the mutex released by pthread_cond_wait() within thread 1 */
rc = pthread_mutex_lock(&g_td.mutex);
......
......@@ -114,8 +114,9 @@ static void *PthreadF02(void *tmp)
clock_gettime(CLOCK_REALTIME, &startTime);
while (1) {
clock_gettime(CLOCK_REALTIME, &currentTime);
if (PthreadTimeF01(currentTime, startTime) > RUNTIME)
if (PthreadTimeF01(currentTime, startTime) > RUNTIME) {
break;
}
}
g_lowDone = 1;
EXIT:
......
......@@ -115,8 +115,9 @@ static void *PthreadF02(void *tmp)
clock_gettime(CLOCK_REALTIME, &startTime);
while (1) {
clock_gettime(CLOCK_REALTIME, &currentTime);
if (PthreadTimeF01(currentTime, startTime) > RUNTIME)
if (PthreadTimeF01(currentTime, startTime) > RUNTIME) {
break;
}
}
g_lowDone = 1;
EXIT:
......
......@@ -58,8 +58,9 @@ static UINT32 Testcase(VOID)
ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
/* Make sure the thread was created before we join it. */
while (g_pthreadSem == PTHREAD_INTHREAD_TEST)
while (g_pthreadSem == PTHREAD_INTHREAD_TEST) {
sleep(1);
}
ret = pthread_join(newTh, &valuePtr);
ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
......
......@@ -77,8 +77,9 @@ static UINT32 Testcase(VOID)
ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
while (g_testCount == 0)
while (g_testCount == 0) {
sleep(1);
}
ret = pthread_cancel(newTh);
ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
......
......@@ -76,8 +76,9 @@ static UINT32 Testcase(VOID)
ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
while (g_pthreadSem == 0)
while (g_pthreadSem == 0) {
sleep(1);
}
ret = pthread_cancel(newTh);
ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
......
......@@ -51,8 +51,9 @@ static VOID *PthreadF01(VOID *argument)
g_pthreadSem = PTHREAD_INMAIN_TEST;
while (g_pthreadSem == PTHREAD_INMAIN_TEST)
while (g_pthreadSem == PTHREAD_INMAIN_TEST) {
sleep(1);
}
pthread_testcancel();
......@@ -73,8 +74,9 @@ static UINT32 Testcase(VOID)
ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
while (g_pthreadSem == PTHREAD_INTHREAD_TEST)
while (g_pthreadSem == PTHREAD_INTHREAD_TEST) {
sleep(1);
}
ret = pthread_cancel(newTh);
ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
......
......@@ -48,8 +48,9 @@ static VOID *PthreadF01(VOID *argument)
g_pthreadSem = PTHREAD_INMAIN_TEST;
while (g_pthreadSem == PTHREAD_INMAIN_TEST)
while (g_pthreadSem == PTHREAD_INMAIN_TEST) {
sleep(1);
}
pthread_testcancel();
......@@ -69,8 +70,9 @@ static UINT32 Testcase(VOID)
ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
while (g_pthreadSem == PTHREAD_INTHREAD_TEST)
while (g_pthreadSem == PTHREAD_INTHREAD_TEST) {
sleep(1);
}
ret = pthread_cancel(newTh);
ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
......
......@@ -48,8 +48,9 @@ static VOID *PthreadF01(VOID *argument)
g_pthreadSem = PTHREAD_INMAIN_TEST;
while (g_pthreadSem == PTHREAD_INMAIN_TEST)
while (g_pthreadSem == PTHREAD_INMAIN_TEST) {
sleep(1);
}
pthread_testcancel();
......@@ -70,8 +71,9 @@ static UINT32 Testcase(VOID)
ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
while (g_pthreadSem == PTHREAD_INTHREAD_TEST)
while (g_pthreadSem == PTHREAD_INTHREAD_TEST) {
sleep(1);
}
ret = pthread_cancel(newTh);
ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
......
......@@ -48,8 +48,9 @@ static VOID *PthreadF01(VOID *argument)
g_pthreadSem = PTHREAD_INMAIN_TEST;
while (g_pthreadSem == PTHREAD_INMAIN_TEST)
while (g_pthreadSem == PTHREAD_INMAIN_TEST) {
sleep(1);
}
pthread_testcancel();
......@@ -71,8 +72,9 @@ static UINT32 Testcase(VOID)
ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
while (g_pthreadSem == PTHREAD_INTHREAD_TEST)
while (g_pthreadSem == PTHREAD_INTHREAD_TEST) {
sleep(1);
}
ret = pthread_cancel(newTh);
ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
......
......@@ -202,10 +202,11 @@ iUINT32 ICunitInit(void)
iUINT32 ICunitRunSingle(ICUNIT_CASE_S *psubCase)
{
if ((g_isSpinorInit == FALSE) && (psubCase->testcase_module == TEST_JFFS))
if ((g_isSpinorInit == FALSE) && (psubCase->testcase_module == TEST_JFFS)) {
dprintf("****** Jffs is not support ! ****** \n");
else
} else {
ICunitRunF(psubCase);
}
return (iUINT32)ICUNIT_SUCCESS;
}
......
......@@ -315,8 +315,9 @@ VOID TestTestHwiDelete(unsigned int irq, VOID *devId)
{
HwiIrqParam stuwIrqPara;
if (OS_INT_ACTIVE)
if (OS_INT_ACTIVE) {
return;
}
stuwIrqPara.swIrq = irq;
stuwIrqPara.pDevId = devId;
......
......@@ -55,7 +55,7 @@ static int Testcase(void)
handle = dlopen(LIBCSO_REAL_PATH, RTLD_NOW);
ICUNIT_ASSERT_NOT_EQUAL(handle, NULL, handle);
func = (int (*)(int))dlsym(handle, SYMBOL_TO_FIND);
func = reinterpret_cast<int (*)(int)>(dlsym(handle, SYMBOL_TO_FIND));
ICUNIT_GOTO_NOT_EQUAL(func, NULL, func, EXIT);
ICUNIT_GOTO_EQUAL(func, SYMBOL_TO_MATCH, func, EXIT);
......@@ -65,7 +65,7 @@ static int Testcase(void)
handle = dlopen(LIBCSO_RELATIVE_PATH, RTLD_NOW);
ICUNIT_ASSERT_NOT_EQUAL(handle, NULL, handle);
func = (int (*)(int))dlsym(handle, SYMBOL_TO_FIND);
func = reinterpret_cast<int (*)(int)>(dlsym(handle, SYMBOL_TO_FIND));
ICUNIT_GOTO_NOT_EQUAL(func, NULL, func, EXIT);
ret = dlclose(handle);
......
......@@ -41,7 +41,7 @@ static int TestCase(void)
wchar_t res2[] = L"abcdmngh";
wchar_t *p, *pnew;
pnew = (wchar_t*)malloc(sizeof(wchar_t) * (wcslen(res) + wcslen(res1)));
pnew = static_cast<wchar_t *>(malloc(sizeof(wchar_t) * (wcslen(res) + wcslen(res1))));
ICUNIT_ASSERT_NOT_EQUAL(pnew, NULL, pnew);
p = wmempcpy(pnew, res, wcslen(res));
......
......@@ -91,7 +91,7 @@ VOID *ShmWriteFunc(VOID *ptr)
shmid = shmget((key_t)1234, sizeof(struct shared_use_st), 0666 | IPC_CREAT);
ICUNIT_ASSERT_NOT_EQUAL_NULL_VOID(shmid, -1, shmid);
shm = shmat(shmid, (void *)0, 0);
shm = shmat(shmid, nullptr, 0);
ICUNIT_ASSERT_NOT_EQUAL_NULL_VOID(shm, INVALID_PTR, shm);
printf("Memory attached at %p\n", shm);
......
......@@ -49,13 +49,13 @@ static int Testcase(VOID)
shm = shmat(shmid, NULL, SHM_REMAP);
ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
shm = shmat(shmid, (const void *)0x100, 0);
shm = shmat(shmid, reinterpret_cast<const void *>(0x100), 0);
ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
shm = shmat(shmid, NULL, 0);
ICUNIT_ASSERT_NOT_EQUAL(shm, (void *)-1, shm);
ICUNIT_ASSERT_NOT_EQUAL(shm, reinterpret_cast<void *>(-1), shm);
ret = shmdt((const void *)0x100);
ret = shmdt(reinterpret_cast<const void *>(0x100));
ICUNIT_ASSERT_EQUAL(ret, -1, shmid);
ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
......
......@@ -42,14 +42,14 @@ static int Testcase(VOID)
ICUNIT_ASSERT_NOT_EQUAL(shmid, -1, shmid);
shared = shmat(shmid, 0, 0);
ICUNIT_ASSERT_NOT_EQUAL(shared, (void *)-1, shared);
ICUNIT_ASSERT_NOT_EQUAL(shared, reinterpret_cast<void *>(-1), shared);
ret = shmdt(shared);
ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
remap = shared;
shared = shmat(shmid, remap, SHM_REMAP);
ICUNIT_ASSERT_NOT_EQUAL(shared, (void *)-1, shared);
ICUNIT_ASSERT_NOT_EQUAL(shared, reinterpret_cast<void *>(-1), shared);
ret = shmdt(shared);
ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
......
......@@ -47,7 +47,7 @@ static int Testcase(void)
ret = fork();
if (ret == 0) {
usleep(100000);
if ((shared = (char *)shmat(shmid, 0, 0)) == (void *)-1) {
if ((shared = static_cast<char *>(shmat(shmid, 0, 0))) == reinterpret_cast<void *>(-1)) {
printf("child : error: shmat()\n");
exit(1);
}
......@@ -72,8 +72,8 @@ static int Testcase(void)
pid = ret;
usleep(50000);
shared = (char *)shmat(shmid, 0, 0);
ICUNIT_ASSERT_NOT_EQUAL(shared, (void *)-1, shared);
shared = static_cast<char *>(shmat(shmid, 0, 0));
ICUNIT_ASSERT_NOT_EQUAL(shared, reinterpret_cast<void *>(-1), shared);
ret = strncpy_s(shared, memSize, testStr, sizeof(testStr));
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
......
......@@ -42,11 +42,11 @@ static int Testcase(void)
ICUNIT_ASSERT_NOT_EQUAL(shmid, -1, shmid);
shared = shmat(shmid, 0, 0);
ICUNIT_ASSERT_EQUAL(shared, (void *)-1, shared);
ICUNIT_ASSERT_EQUAL(shared, reinterpret_cast<void *>(-1), shared);
ICUNIT_ASSERT_EQUAL(errno, EACCES, errno);
shared = shmat(shmid, 0, SHM_RDONLY);
ICUNIT_ASSERT_NOT_EQUAL(shared, (void *)-1, shared);
ICUNIT_ASSERT_NOT_EQUAL(shared, reinterpret_cast<void *>(-1), shared);
ret = shmdt(shared);
ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
......
......@@ -88,14 +88,14 @@ static int Testcase(void)
int ret;
int pid;
void *ptr = (void *)signal(SIGTERM, ExitChildren);
void *ptr = reinterpret_cast<void *>(signal(SIGTERM, ExitChildren));
ICUNIT_ASSERT_NOT_EQUAL(ptr, NULL, ptr);
shmid = shmget(IPC_PRIVATE, sizeof(int), IPC_CREAT | 0600);
ICUNIT_ASSERT_NOT_EQUAL(shmid, -1, shmid);
g_shmptr = (int *)shmat(shmid, 0, 0);
ICUNIT_ASSERT_NOT_EQUAL(g_shmptr, (int *)-1, g_shmptr);
ICUNIT_ASSERT_NOT_EQUAL(g_shmptr, reinterpret_cast<int *>(-1), g_shmptr);
*g_shmptr = 0;
......
......@@ -43,9 +43,9 @@ static int testcase(void)
shmfd = shm_open("test_1", O_RDWR | O_CREAT | O_EXCL, 0644);
ICUNIT_ASSERT_NOT_EQUAL(shmfd, -1, shmfd);
writebuf = (char*)malloc(pageSize);
writebuf = static_cast<char *>(malloc(pageSize));
ICUNIT_ASSERT_NOT_EQUAL(writebuf, NULL, writebuf);
readbuf = (char*)malloc(pageSize);
readbuf = static_cast<char *>(malloc(pageSize));
ICUNIT_GOTO_NOT_EQUAL(readbuf, NULL, readbuf, EXIT);
(void)memset_s(writebuf, pageSize, 0xf, pageSize);
......
......@@ -49,9 +49,9 @@ static int testcase(void)
shmfd = shm_open("test_2", O_RDONLY | O_CREAT, 00664);
ICUNIT_ASSERT_NOT_EQUAL(shmfd, -1, shmfd);
writebuf = (char*)malloc(pageSize);
writebuf = static_cast<char *>(malloc(pageSize));
ICUNIT_ASSERT_NOT_EQUAL(writebuf, NULL, writebuf);
readbuf = (char*)malloc(pageSize);
readbuf = static_cast<char *>(malloc(pageSize));
ICUNIT_ASSERT_NOT_EQUAL(readbuf, NULL, readbuf);
(void)memset_s(writebuf, pageSize, 0xf, pageSize);
......
......@@ -45,7 +45,7 @@ static int Testcase(void)
ret = fork();
if (ret == 0) {
shared = (int *)shmat(shmid, NULL, 0);
if (shared == (int *)-1) {
if (shared == reinterpret_cast<int *>(-1)) {
exit(1);
}
*shared = 2;
......@@ -55,7 +55,7 @@ static int Testcase(void)
} else {
usleep(20000);
shared = (int *)shmat(shmid, NULL, 0);
ICUNIT_ASSERT_NOT_EQUAL(shared, (int *)-1, shared);
ICUNIT_ASSERT_NOT_EQUAL(shared, reinterpret_cast<int *>(-1), shared);
ICUNIT_ASSERT_EQUAL(*shared, 2, *shared);
......
......@@ -71,7 +71,7 @@ static int Testcase(void)
printf("err: malloc size invalid\n");
return -1;
}
buf = (char *)malloc(pageSize);
buf = static_cast<char *>(malloc(pageSize));
ICUNIT_ASSERT_NOT_EQUAL(buf, NULL, buf);
(void)memset_s(buf, pageSize, 0xf, pageSize);
......
......@@ -49,7 +49,7 @@ static int Testcase(void)
fd = open(file, O_CREAT | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
ICUNIT_ASSERT_NOT_EQUAL(fd, -1, fd);
invalueAddr = (void *)(VALIDE_ADDR | ADDR_OFFSET);
invalueAddr = reinterpret_cast<void *>(VALIDE_ADDR | ADDR_OFFSET);
mem = mmap(invalueAddr, len, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED, fd, 0);
ICUNIT_GOTO_EQUAL(mem, MAP_FAILED, mem, EXIT);
ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT);
......
......@@ -40,24 +40,26 @@ static int Testcase(void)
const char *str = "Hi, OHOS.";
/* sigprocmask 内核系统调用接口通过arch_copy_from_user拷贝用户参数 */
ret = sigprocmask(SIG_BLOCK, (sigset_t *)1, &oldset);
ret = sigprocmask(SIG_BLOCK, reinterpret_cast<sigset_t *>(1), &oldset);
ICUNIT_ASSERT_EQUAL(ret, -1, ret);
ICUNIT_ASSERT_EQUAL(errno, EFAULT, errno);
ret = sigprocmask(SIG_BLOCK, (sigset_t *)INVALID_USER_VADDR, &oldset);
ret = sigprocmask(SIG_BLOCK, reinterpret_cast<sigset_t *>(INVALID_USER_VADDR), &oldset);
ICUNIT_ASSERT_EQUAL(ret, -1, ret);
ICUNIT_ASSERT_EQUAL(errno, EFAULT, errno);
/* sigprocmask 内核系统调用接口通过arch_copy_to_user将内核参数拷贝至用户 */
ret = sigprocmask(SIG_BLOCK, (sigset_t *)INVALID_USER_VADDR, (sigset_t *)1);
ret = sigprocmask(SIG_BLOCK, reinterpret_cast<sigset_t *>(INVALID_USER_VADDR), reinterpret_cast<sigset_t *>(1));
ICUNIT_ASSERT_EQUAL(ret, -1, ret);
ICUNIT_ASSERT_EQUAL(errno, EFAULT, errno);
ret = sigprocmask(SIG_BLOCK, (sigset_t *)INVALID_USER_VADDR, (sigset_t *)INVALID_USER_VADDR);
ret = sigprocmask(SIG_BLOCK, reinterpret_cast<sigset_t *>(INVALID_USER_VADDR),
reinterpret_cast<sigset_t *>(INVALID_USER_VADDR));
ICUNIT_ASSERT_EQUAL(ret, -1, ret);
ICUNIT_ASSERT_EQUAL(errno, EFAULT, errno);
ret = sigprocmask(SIG_BLOCK, (sigset_t *)INVALID_USER_VADDR, (sigset_t *)str);
ret = sigprocmask(SIG_BLOCK, reinterpret_cast<sigset_t *>(INVALID_USER_VADDR),
reinterpret_cast<sigset_t *>(const_cast<char *>(str)));
ICUNIT_ASSERT_EQUAL(ret, -1, ret);
ICUNIT_ASSERT_EQUAL(errno, EFAULT, errno);
......
......@@ -53,7 +53,7 @@ static int Testcase(VOID)
fd = open(MOUSE_DEV_PATH, O_RDWR, 0666);
ICUNIT_ASSERT_NOT_EQUAL(fd, -1, fd);
buf = (char *)malloc(MOUSE_DATA_LEN);
buf = static_cast<char *>(malloc(MOUSE_DATA_LEN));
ICUNIT_ASSERT_NOT_EQUAL(buf, NULL, buf);
ret = memset_s(buf, MOUSE_DATA_LEN, 0, MOUSE_DATA_LEN);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
......
......@@ -51,7 +51,7 @@ static int Testcase(VOID)
fd = open(STORAGE_DEV_PATH, O_RDWR, 0666);
ICUNIT_ASSERT_NOT_EQUAL(fd, -1, fd);
buf = (char *)malloc(STORAGE_DATA_LEN);
buf = static_cast<char *>(malloc(STORAGE_DATA_LEN));
ICUNIT_ASSERT_NOT_EQUAL(buf, NULL, buf);
ret = memset_s(buf, STORAGE_DATA_LEN, 0, STORAGE_DATA_LEN);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
......
......@@ -62,20 +62,20 @@ static int LiteIpcTest(void)
/* testing mmap liteipc mem pool with different size and flag */
retptr = mmap(nullptr, 1024 * 4096, PROT_READ, MAP_PRIVATE, fd, 0);
ICUNIT_ASSERT_EQUAL((int)(intptr_t)retptr, -1, retptr);
ICUNIT_ASSERT_EQUAL(static_cast<int>(static_cast<intptr_t>(retptr)), -1, retptr);
//retptr = mmap(nullptr, 0, PROT_READ, MAP_PRIVATE, fd, 0);
//ICUNIT_ASSERT_EQUAL((int)(intptr_t)retptr, -1, retptr);
retptr = mmap(nullptr, -1, PROT_READ, MAP_PRIVATE, fd, 0);
ICUNIT_ASSERT_EQUAL((int)(intptr_t)retptr, -1, retptr);
ICUNIT_ASSERT_EQUAL(static_cast<int>(static_cast<intptr_t>(retptr)), -1, retptr);
retptr = mmap(nullptr, 4096, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
ICUNIT_ASSERT_EQUAL((int)(intptr_t)retptr, -1, retptr);
ICUNIT_ASSERT_EQUAL(static_cast<int>(static_cast<intptr_t>(retptr)), -1, retptr);
retptr = mmap(nullptr, 4096, PROT_READ, MAP_SHARED, fd, 0);
ICUNIT_ASSERT_EQUAL((int)(intptr_t)retptr, -1, retptr);
ICUNIT_ASSERT_EQUAL(static_cast<int>(static_cast<intptr_t>(retptr)), -1, retptr);
retptr = mmap(nullptr, 1, PROT_READ, MAP_PRIVATE, fd, 0);
ICUNIT_ASSERT_NOT_EQUAL((int)(intptr_t)retptr, -1, retptr);
ICUNIT_ASSERT_NOT_EQUAL(static_cast<int>(static_cast<intptr_t>(retptr)), -1, retptr);
retptr = mmap(nullptr, 4095, PROT_READ, MAP_PRIVATE, fd, 0);
ICUNIT_ASSERT_EQUAL((int)(intptr_t)retptr, -1, retptr);
ICUNIT_ASSERT_EQUAL(static_cast<int>(static_cast<intptr_t>(retptr)), -1, retptr);
/* testing read/write api */
char buf[10] = {0};
......@@ -121,7 +121,7 @@ static int TestCase(void)
ICUNIT_ASSERT_NOT_EQUAL(fd, -1, fd);
retptr = mmap(nullptr, 16 * 4096, PROT_READ, MAP_PRIVATE, fd, 0);
ICUNIT_ASSERT_NOT_EQUAL((int)(intptr_t)retptr, -1, retptr);
ICUNIT_ASSERT_NOT_EQUAL(static_cast<int>(static_cast<intptr_t>(retptr)), -1, retptr);
ret = ioctl(fd, IPC_SET_CMS, 0);
ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret);
ret = ioctl(fd, IPC_SET_CMS, 200);
......
......@@ -65,7 +65,7 @@ static int CallTestServiceLoop(uint32_t id)
ret = GetService(g_ipcFd, g_serviceName, sizeof(g_serviceName), &serviceHandle);
ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret);
retptr = mmap(NULL, 4096, PROT_READ, MAP_PRIVATE, g_ipcFd, 0);
ICUNIT_ASSERT_NOT_EQUAL((int)(intptr_t)retptr, -1, retptr);
ICUNIT_ASSERT_NOT_EQUAL(static_cast<int>(static_cast<intptr_t>(retptr)), -1, retptr);
ret = GetService(g_ipcFd, g_serviceName, sizeof(g_serviceName), &serviceHandle);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
......@@ -141,7 +141,7 @@ static int TestServiceLoop(void)
ret = RegService(g_ipcFd, g_serviceName, sizeof(g_serviceName), &serviceHandle);
ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret);
retptr = mmap(NULL, 4096, PROT_READ, MAP_PRIVATE, g_ipcFd, 0);
ICUNIT_ASSERT_NOT_EQUAL((int)(intptr_t)retptr, -1, retptr);
ICUNIT_ASSERT_NOT_EQUAL(static_cast<int>(static_cast<intptr_t>(retptr)), -1, retptr);
ret = RegService(g_ipcFd, g_serviceName, sizeof(g_serviceName), &serviceHandle);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
......
......@@ -40,7 +40,7 @@ static UINT32 Testcase(VOID)
ret = pipe(pipeFd);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
shmid = shmget((key_t)IPC_PRIVATE, sizeof(int), 0666 | IPC_CREAT); // 0666 the authority of the shm
shmid = shmget(static_cast<key_t>(IPC_PRIVATE), sizeof(int), 0666 | IPC_CREAT); // 0666 the authority of the shm
ICUNIT_ASSERT_NOT_EQUAL(shmid, -1, shmid);
sharedflag = (int *)shmat(shmid, NULL, 0);
*sharedflag = 0;
......
......@@ -42,7 +42,7 @@ static UINT32 Testcase(VOID)
ret = pipe(pipeFd);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
shmid = shmget((key_t)IPC_PRIVATE, sizeof(int), 0666 | IPC_CREAT); // 0666 the authority of the shm
shmid = shmget(static_cast<key_t>(IPC_PRIVATE), sizeof(int), 0666 | IPC_CREAT); // 0666 the authority of the shm
ICUNIT_ASSERT_NOT_EQUAL(shmid, -1, shmid);
sharedflag = (int *)shmat(shmid, NULL, 0);
*sharedflag = 0;
......
......@@ -56,7 +56,7 @@ static int PipecommonWrite()
printf("signal error\n");
}
shmid = shmget((key_t)IPC_PRIVATE, sizeof(int), 0666 | IPC_CREAT); // 0666 the authority of the shm
shmid = shmget(static_cast<key_t>(IPC_PRIVATE), sizeof(int), 0666 | IPC_CREAT); // 0666 the authority of the shm
ICUNIT_ASSERT_NOT_EQUAL(shmid, -1, shmid);
sharedflag = (int *)shmat(shmid, NULL, 0);
*sharedflag = 0;
......
......@@ -80,7 +80,7 @@ static UINT32 TestCase(VOID)
sigaddset(&newset, SIGCHLD);
timeout.tv_nsec = 1;
timeout.tv_sec = 3; // 3, set the sec of timeout.
ret = sigtimedwait(&newset, (siginfo_t *)2, &timeout); // 2, wait for signal num
ret = sigtimedwait(&newset, reinterpret_cast<siginfo_t *>(2), &timeout); // 2, wait for signal num
printf("ret = %d errno = %d EFAULT = %d\n", ret, errno, EFAULT);
if (ret != -1) {
exit(ret);
......
......@@ -73,7 +73,7 @@ static UINT32 TestCase(VOID)
exit(errno);
}
ret = sigsuspend((sigset_t *)2); // 2, suspend signal num.
ret = sigsuspend(reinterpret_cast<sigset_t *>(2)); // 2, suspend signal num.
if (ret != -1) {
exit(ret);
}
......@@ -89,7 +89,7 @@ static UINT32 TestCase(VOID)
exit(errno);
}
ret = sigpending((sigset_t *)2); // 2, pending signal num.
ret = sigpending(reinterpret_cast<sigset_t *>(2)); // 2, pending signal num.
if (ret != -1) {
exit(ret);
}
......
......@@ -51,7 +51,7 @@ static int TestPipeMultiProcess()
int flag = fcntl(*readFd, F_GETFL);
fcntl(*readFd, F_SETFL, flag | O_NONBLOCK);
shmid = shmget((key_t)IPC_PRIVATE, sizeof(int), 0666 | IPC_CREAT); // 0666 the authority of the shm
shmid = shmget(static_cast<key_t>(IPC_PRIVATE), sizeof(int), 0666 | IPC_CREAT); // 0666 the authority of the shm
ICUNIT_ASSERT_NOT_EQUAL(shmid, -1, shmid);
sharedflag = (int *)shmat(shmid, NULL, 0);
*sharedflag = 0;
......
......@@ -47,7 +47,7 @@ static int TestRaiseIgnore(void)
g_sigCount = 0;
// trigger one
ret = (void *)signal(sig, SigPrint);
ret = reinterpret_cast<void *>(signal(sig, SigPrint));
ICUNIT_ASSERT_NOT_EQUAL(ret, NULL, ret);
retValue = raise(sig);
......@@ -55,13 +55,13 @@ static int TestRaiseIgnore(void)
usleep(1000); // 1000, Used to calculate the delay time.
// trigger ignore
ret = (void *)signal(sig, SIG_IGN);
ret = reinterpret_cast<void *>(signal(sig, SIG_IGN));
ICUNIT_ASSERT_NOT_EQUAL(ret, NULL, ret);
retValue = raise(sig);
ICUNIT_ASSERT_EQUAL(retValue, 0, retValue);
// trigger one
ret = (void *)signal(sig, SigPrint);
ret = reinterpret_cast<void *>(signal(sig, SigPrint));
ICUNIT_ASSERT_NOT_EQUAL(ret, NULL, ret);
retValue = raise(sig);
ICUNIT_ASSERT_EQUAL(retValue, 0, retValue);
......
......@@ -63,8 +63,8 @@ static void *ThreadSetFunc2(void *arg)
pthread_exit((void *)NULL);
return NULL;
EXIT:
pthread_exit((void *)-1);
return (void *)-1;
pthread_exit(reinterpret_cast<void *>(-1));
return reinterpret_cast<void *>(-1);
}
static void *ThreadSetDfl(void *arg)
......@@ -76,8 +76,8 @@ static void *ThreadSetDfl(void *arg)
pthread_exit((void *)NULL);
return NULL;
EXIT:
pthread_exit((void *)-1);
return (void *)-1;
pthread_exit(reinterpret_cast<void *>(-1));
return reinterpret_cast<void *>(-1);
}
static void *ThreadKill(void *arg)
......@@ -90,8 +90,8 @@ static void *ThreadKill(void *arg)
pthread_exit((void *)NULL);
return NULL;
EXIT:
pthread_exit((void *)-1);
return (void *)-1;
pthread_exit(reinterpret_cast<void *>(-1));
return reinterpret_cast<void *>(-1);
}
static int TestSigMultiPthread(void)
......@@ -119,15 +119,15 @@ static int TestSigMultiPthread(void)
exit(ret);
}
pthread_join(thread, (void **)&status1);
pthread_join(thread, reinterpret_cast<void **>(&status1));
if ((int)(intptr_t)status1 != 0) {
exit(-1);
}
pthread_join(thread1, (void **)&status1);
pthread_join(thread1, reinterpret_cast<void **>(&status1));
if ((int)(intptr_t)status1 != 0) {
exit(-1);
}
pthread_join(thread2, (void **)&status1);
pthread_join(thread2, reinterpret_cast<void **>(&status1));
if ((int)(intptr_t)status1 != 0) {
exit(-1);
}
......
......@@ -49,7 +49,7 @@ static UINT32 TestCase(VOID)
ICUNIT_ASSERT_EQUAL(retval, -1, retval);
ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
printf("----------------------------------\n");
retval = sigprocmask(SIG_BLOCK, (sigset_t *)1, &oldset);
retval = sigprocmask(SIG_BLOCK, reinterpret_cast<sigset_t *>(1), &oldset);
ICUNIT_ASSERT_EQUAL(retval, -1, retval);
ICUNIT_ASSERT_EQUAL(errno, EFAULT, errno);
printf("----------------------------------\n");
......
......@@ -43,7 +43,7 @@ static UINT32 TestCase(VOID)
ioctl(fd, TRACE_STOP, NULL);
buffer= (char *)malloc(size);
buffer = (char *)malloc(size);
if (buffer == NULL) {
printf("Read buffer malloc failed!\n");
goto EXIT;
......
......@@ -118,7 +118,7 @@ static UINT32 testcase(VOID)
locale_t newloc = nullptr;
char *pathList[] = {"/storage/zh_CN.UTF-8"};
char *streamList[] = {(char *)fileWords};
char *streamList[] = {reinterpret_cast<char *>(fileWords)};
int streamLen[] = {sizeof(fileWords) - 2};
newloc = duplocale(oldloc);
......
......@@ -41,8 +41,8 @@ static UINT32 testcase(VOID) {
setlocale(LC_NUMERIC, "");
/* echo the nl_langinfo_l */
printf("%s\n", nl_langinfo_l(CODESET, (locale_t)"en_US.UTF-8"));
printf("%s\n", nl_langinfo_l(RADIXCHAR, (locale_t)"en_US.UTF-8"));
printf("%s\n", nl_langinfo_l(CODESET, reinterpret_cast<locale_t>(const_cast<char *>("en_US.UTF-8"))));
printf("%s\n", nl_langinfo_l(RADIXCHAR, reinterpret_cast<locale_t>(const_cast<char *>("en_US.UTF-8"))));
/* set the locale info */
setenv("MUSL_LOCPATH", "/storage", 1);
......@@ -53,10 +53,10 @@ static UINT32 testcase(VOID) {
setlocale(LC_NUMERIC, "");
/* echo the nl_langinfo */
printf("%s\n", nl_langinfo_l(CODESET, (locale_t)"zh_CN.UTF-8"));
printf("%s\n", nl_langinfo_l(RADIXCHAR, (locale_t)"zh_CN.UTF-8"));
printf("%s\n", nl_langinfo_l(CODESET, reinterpret_cast<locale_t>(const_cast<char *>("zh_CN.UTF-8"))));
printf("%s\n", nl_langinfo_l(RADIXCHAR, reinterpret_cast<locale_t>(const_cast<char *>("zh_CN.UTF-8"))));
char *string = nl_langinfo_l(CRNCYSTR, (locale_t)"zh_CN.UTF-8");
char *string = nl_langinfo_l(CRNCYSTR, reinterpret_cast<locale_t>(const_cast<char *>("zh_CN.UTF-8")));
ICUNIT_ASSERT_NOT_EQUAL_NULL(string, NULL, string);
setlocale(LC_ALL, "C");
......
......@@ -44,7 +44,7 @@ static UINT32 testcase(VOID)
char fileWords[] = "/dev/disk/by-uuid/c4992556-a86e-45e8-ba5f-190b16a9073x /usr1 ext3 errors=remount-ro,nofail 0 1";
char *pathList[] = {"/etc/fstab"};
char *streamList[] = {(char *)fileWords};
char *streamList[] = {static_cast<char *>(fileWords)};
int streamLen[] = {sizeof(fileWords)};
int flag = PrepareFileEnv(pathList, streamList, streamLen, 1);
......
......@@ -31,9 +31,9 @@
#include "It_test_misc.h"
#include "sys/utsname.h"
#define INVALID_ADDR_FIRST_PAGE ((struct utsname *)0x1200000)
#define INVALID_ADDR_USER_ADDR ((struct utsname *)0x1000000)
#define INVALID_ADDR_KERNEL_READONLY_ADDR ((struct utsname *)0x4016c75c)
#define INVALID_ADDR_FIRST_PAGE (reinterpret_cast<struct utsname *>(0x1200000))
#define INVALID_ADDR_USER_ADDR (reinterpret_cast<struct utsname *>(0x1000000))
#define INVALID_ADDR_KERNEL_READONLY_ADDR (reinterpret_cast<struct utsname *>(0x4016c75c))
static UINT32 TestCase(VOID)
{
......
......@@ -43,11 +43,11 @@ static VOID *PthreadF01(VOID *mq)
LOS_AtomicInc(&g_testCount);
pthread_exit((void *)0);
pthread_exit(nullptr);
return NULL;
EXIT:
pthread_exit((void *)0);
pthread_exit(nullptr);
g_testCount = 0;
return NULL;
}
......@@ -64,11 +64,11 @@ static VOID *PthreadF02(VOID *mq)
}
LOS_AtomicInc(&g_testCount);
pthread_exit((void *)0);
pthread_exit(nullptr);
return NULL;
EXIT:
pthread_exit((void *)0);
pthread_exit(nullptr);
g_testCount = 0;
return NULL;
}
......@@ -85,11 +85,11 @@ static VOID *PthreadF03(VOID *mq)
}
LOS_AtomicInc(&g_testCount);
pthread_exit((void *)0);
pthread_exit(nullptr);
return NULL;
EXIT:
pthread_exit((void *)0);
pthread_exit(nullptr);
g_testCount = 0;
return NULL;
}
......@@ -107,11 +107,11 @@ static VOID *PthreadF04(VOID *mq)
LOS_AtomicInc(&g_testCount);
pthread_exit((void *)0);
pthread_exit(nullptr);
return NULL;
EXIT:
pthread_exit((void *)0);
pthread_exit(nullptr);
g_testCount = 0;
return NULL;
}
......
......@@ -50,11 +50,11 @@ static VOID *PthreadF01(VOID *info)
LOS_AtomicInc(&g_testCount);
pthread_exit((void *)0);
pthread_exit(nullptr);
return NULL;
EXIT:
pthread_exit((void *)0);
pthread_exit(nullptr);
g_testCount = 0;
return NULL;
}
......@@ -74,11 +74,11 @@ static VOID *PthreadF02(VOID *info)
LOS_AtomicInc(&g_testCount);
pthread_exit((void *)0);
pthread_exit(nullptr);
return NULL;
EXIT:
pthread_exit((void *)0);
pthread_exit(nullptr);
g_testCount = 0;
return NULL;
}
......
......@@ -41,11 +41,11 @@ static VOID *PthreadF01(VOID *arg)
}
LOS_AtomicInc(&g_testCount);
pthread_exit((void *)0);
pthread_exit(nullptr);
return NULL;
EXIT:
pthread_exit((void *)0);
pthread_exit(nullptr);
g_testCount = 0;
return NULL;
}
......@@ -63,12 +63,12 @@ static VOID *PthreadF02(VOID *arg)
LOS_AtomicInc(&g_testCount);
pthread_exit((void *)0);
pthread_exit(nullptr);
return NULL;
EXIT:
g_testCount = 0;
pthread_exit((void *)0);
pthread_exit(nullptr);
return NULL;
}
......
......@@ -34,9 +34,9 @@ static VOID *pthread_f01(void *argument)
{
g_testCount = pthread_self();
pthread_exit((void *)8);
pthread_exit(static_cast<void *>(8)); // 8: exit value for testing
return (void *)9;
return static_cast<void *>(9); // 9: return value for testing
}
static UINT32 Testcase(VOID)
{
......
......@@ -42,12 +42,13 @@ static VOID *pthread_f01(void *argument)
{
g_testCount++;
pthread_cleanup_push(PthreadCleanF01, (void *)8);
if (argument)
return (void *)8;
pthread_cleanup_push(PthreadCleanF01, static_cast<void *>(8)); // 8:arg that routine is called with
if (argument) {
return static_cast<void *>(8); // 8: return value for testing if argument is not NULL
}
pthread_cleanup_pop(0);
return (void *)9;
return static_cast<void *>(9); // 9: return value for testing
}
static UINT32 Testcase(VOID)
......
......@@ -42,11 +42,11 @@ static VOID *pthread_f01(void *argument)
{
g_testCount++;
pthread_cleanup_push(PthreadCleanF01, (void *)8);
pthread_exit((void *)8);
pthread_cleanup_push(PthreadCleanF01, static_cast<void *>(8)); // 8: arg that routine is called with
pthread_exit(static_cast<void *>(8)); // 8: exit value for testing
pthread_cleanup_pop(1);
return (void *)9;
return static_cast<void *>(9); // 9: return value for testing
}
static UINT32 Testcase(VOID)
......
......@@ -43,11 +43,11 @@ static VOID *pthread_f01(void *argument)
g_testCount++;
LosTaskDelay(5);
pthread_cleanup_push(PthreadCleanF01, (void *)8);
pthread_cleanup_push(PthreadCleanF01, static_cast<void *>(8)); // 8: arg that routine is called with
pthread_testcancel();
pthread_cleanup_pop(1);
return (void *)9;
return static_cast<void *>(9); // 9: return value for testing
}
static UINT32 Testcase(VOID)
......
......@@ -46,13 +46,13 @@ static VOID *pthread_f01(void *argument)
{
g_testCount++;
pthread_cleanup_push(PthreadCleanF01, (void *)9);
pthread_cleanup_push(PthreadCleanF01, (void *)8);
pthread_exit((void *)8);
pthread_cleanup_push(PthreadCleanF01, static_cast<void *>(9)); // 9: arg that routine is called with
pthread_cleanup_push(PthreadCleanF01, static_cast<void *>(8)); // 8: arg that routine is called with
pthread_exit(static_cast<void *>(8)); // 8: exit value for testing
pthread_cleanup_pop(1);
pthread_cleanup_pop(1);
return (void *)9;
return static_cast<void *>(9); // 9: return value for testing
}
static UINT32 Testcase(VOID)
......
......@@ -34,7 +34,7 @@ static VOID *pthread_f01(void *argument)
{
g_testCount++;
return (void *)9;
return static_cast<void *>(9); // 9: return value for testing
}
static UINT32 Testcase(VOID)
......
......@@ -34,8 +34,8 @@ static VOID *pthread_f01(void *argument)
{
g_testCount++;
pthread_exit((void *)8);
return (void *)9;
pthread_exit(static_cast<void *>(8)); // 8: exit value for testing
return static_cast<void *>(9); // 9: return value for testing
}
static UINT32 Testcase(VOID)
{
......
......@@ -37,7 +37,7 @@ static VOID *pthread_f01(void *argument)
pthread_testcancel();
g_testCount++;
return (void *)9;
return static_cast<void *>(9); // 9: return value for testing
}
static UINT32 Testcase(VOID)
{
......
......@@ -39,7 +39,7 @@ static VOID *pthread_f01(void *argument)
ret = pthread_join(g_newTh, NULL);
ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT);
EXIT:
return (void *)9;
return static_cast<void *>(9); // 9: return value for testing
}
static UINT32 Testcase(VOID)
......
......@@ -43,7 +43,7 @@ static VOID *pthread_f01(void *argument)
g_testCount++;
ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
EXIT:
return (void *)9;
return static_cast<void *>(9); // 9: return value for testing
}
static VOID *pthread_f02(void *argument)
......@@ -59,7 +59,7 @@ static VOID *pthread_f02(void *argument)
g_testCount++;
ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT);
EXIT:
return (void *)8;
return static_cast<void *>(8); // 8: return value for testing
}
static VOID *PthreadF03(void *argument)
......@@ -76,7 +76,7 @@ static VOID *PthreadF03(void *argument)
ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT);
EXIT:
return (void *)7;
return static_cast<void *>(7); // 7: return value for testing
}
static UINT32 Testcase(VOID)
......
......@@ -47,7 +47,7 @@ static VOID *pthread_f01(void *argument)
g_testCnt1++;
ICUNIT_GOTO_EQUAL(g_testCnt1, 4, g_testCnt1, EXIT);
EXIT:
return (void *)9;
return reinterpret_cast<void *>(9); // 9: return value for testing
}
static VOID *pthread_f02(void *argument)
......@@ -67,7 +67,7 @@ static VOID *pthread_f02(void *argument)
g_testCnt1++;
ICUNIT_GOTO_EQUAL(g_testCnt1, 5, g_testCnt1, EXIT);
EXIT:
return (void *)8;
return reinterpret_cast<void *>(8); // 8:return value for testing
}
static VOID *PthreadF03(void *argument)
......@@ -88,7 +88,7 @@ static VOID *PthreadF03(void *argument)
ICUNIT_GOTO_EQUAL(g_testCnt1, 6, g_testCnt1, EXIT);
EXIT:
return (void *)7;
return reinterpret_cast<void *>(7); // 7: return value for testing
}
static UINT32 Testcase(VOID)
{
......@@ -108,8 +108,9 @@ static UINT32 Testcase(VOID)
ret = pthread_create(&newTh3, NULL, PthreadF03, NULL);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
while (g_testCnt1 < 6)
while (g_testCnt1 < 6) { // 6: threshold for calling sleep
sleep(1);
}
ICUNIT_ASSERT_EQUAL(g_testCnt1, 6, g_testCnt1);
......
......@@ -36,7 +36,7 @@ static VOID *PthreadF01(void *argument)
LosTaskDelay(2);
pthread_testcancel();
g_testCount++;
return (void *)9;
return static_cast<void *>(9); // 9: return value for testing
}
static UINT32 Testcase(VOID)
......
......@@ -36,7 +36,7 @@ static VOID *pthread_f01(void *argument)
LosTaskDelay(2);
g_testCount++;
return (void *)9;
return static_cast<void *>(9); // 9: return value for testing
}
static UINT32 Testcase(VOID)
{
......
......@@ -36,7 +36,7 @@ static VOID *pthread_f01(void *argument)
LosTaskDelay(2);
g_testCount++;
return (void *)9;
return static_cast<void *>(9); // 9: return value for testing
}
static UINT32 Testcase(VOID)
{
......
......@@ -47,7 +47,7 @@ static VOID *pthread_f02(void *argument)
ICUNIT_GOTO_EQUAL(param.sched_priority, 3, param.sched_priority, EXIT);
EXIT:
return (void *)9;
return static_cast<void *>(9); // 9: return value for testing
}
static VOID *pthread_f01(void *argument)
......@@ -89,7 +89,7 @@ static VOID *pthread_f01(void *argument)
ret = pthread_attr_destroy(&attr);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
EXIT:
return (void *)9;
return static_cast<void *>(9); // 9: return value for testing
}
static UINT32 Testcase(VOID)
{
......
......@@ -39,7 +39,7 @@ static VOID *pthread_f01(void *argument)
g_testCount++;
EXIT:
return (void *)9;
return static_cast<void *>(9); // 9: return value for testing
}
static UINT32 Testcase(VOID)
......
......@@ -37,7 +37,7 @@ static VOID *pthread_f01(void *argument)
g_testCount++;
EXIT:
return (void *)9;
return static_cast<void *>(9); // 9: return value for testing
}
static UINT32 Testcase(VOID)
......
......@@ -49,7 +49,7 @@ static VOID *pthread_f01(void *argument)
ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // not reachable
EXIT:
return (void *)9;
return static_cast<void *>(9); // 9: return value for testing
}
static UINT32 Testcase(VOID)
{
......
......@@ -53,7 +53,7 @@ static VOID *pthread_f01(void *argument)
g_testCount++;
ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT);
EXIT:
return (void *)9;
return static_cast<void *>(9); // 9: return value for testing
}
static VOID *pthread_f02(void *argument)
......@@ -79,7 +79,7 @@ static VOID *pthread_f02(void *argument)
g_testCount++;
ICUNIT_GOTO_EQUAL(g_testCount, 6, g_testCount, EXIT);
EXIT:
return (void *)8;
return static_cast<void *>(8); // 8: return value for testing
}
static VOID *PthreadF03(void *argument)
......@@ -107,7 +107,7 @@ static VOID *PthreadF03(void *argument)
ICUNIT_GOTO_EQUAL(g_testCount, 8, g_testCount, EXIT);
EXIT:
return (void *)7;
return static_cast<void *>(7); // 7: return value for testing
}
static void PthreadKeyF01(void *threadLog)
......
......@@ -71,7 +71,7 @@ static VOID *pthread_f01(void *argument)
g_testCount++;
ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT);
EXIT:
return (void *)9;
return static_cast<void *>(9); // 9: return value for testing
}
static VOID *pthread_f02(void *argument)
......@@ -115,7 +115,7 @@ static VOID *pthread_f02(void *argument)
g_testCount++;
ICUNIT_GOTO_EQUAL(g_testCount, 7, g_testCount, EXIT);
EXIT:
return (void *)8;
return static_cast<void *>(8); // 8: return value for testing
}
static void PthreadKeyF01(void *threadLog)
{
......
......@@ -49,9 +49,9 @@ static VOID *pthread_f01(void *argument)
g_testCount++;
ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT);
pthread_exit((void *)7);
pthread_exit(static_cast<void *>(7)); // 7: exit value for testing
EXIT:
return (void *)9;
return static_cast<void *>(9); // 9: return value for testing
}
static void PthreadKeyF01(void *threadLog)
......
......@@ -51,7 +51,7 @@ static VOID *pthread_f01(void *argument)
pthread_testcancel();
EXIT:
return (void *)9;
return static_cast<void *>(9); // 9: return value for testing
}
static void PthreadKeyF01(void *threadLog)
......
......@@ -41,7 +41,7 @@ static VOID *pthread_f01(void *argument)
ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT); // failed, =2
EXIT:
return (void *)9;
return static_cast<void *>(9); // 9: return value for testing
}
static UINT32 Testcase(VOID)
......
......@@ -33,7 +33,7 @@
static VOID *pthread_f02(void *argument)
{
g_testCount++;
return (void *)8;
return static_cast<void *>(8); // 8: return value for testing
}
static VOID *pthread_f01(void *argument)
{
......@@ -54,7 +54,7 @@ static VOID *pthread_f01(void *argument)
ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
EXIT:
return (void *)9;
return static_cast<void *>(9); // 9: return value for testing
}
static UINT32 Testcase(VOID)
......
......@@ -50,7 +50,7 @@ static VOID *pthread_f01(void *argument)
ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
EXIT:
return (void *)9;
return static_cast<void *>(9); // 9: return value for testing
}
static UINT32 Testcase(VOID)
{
......
......@@ -45,7 +45,7 @@ static VOID *pthread_f01(void *argument)
ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
EXIT:
return (void *)9;
return static_cast<void *>(9); // 9: return value for testing
}
static UINT32 Testcase(VOID)
......
......@@ -51,7 +51,7 @@ static VOID *pthread_f01(void *argument)
ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
EXIT:
return (void *)9;
return static_cast<void *>(9); // 9: return value for testing
}
static UINT32 Testcase(VOID)
{
......
......@@ -52,7 +52,7 @@ static VOID *pthread_f01(void *argument)
ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT);
EXIT:
return (void *)9;
return reinterpret_cast<void *>(9); // 9: return value for testing
}
static UINT32 Testcase(VOID)
{
......
......@@ -44,7 +44,7 @@ static VOID *pthread_f02(void *argument)
ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT);
EXIT:
return (void *)9;
return static_cast<void *>(9); // 9: return value for testing
}
static VOID *pthread_f01(void *argument)
......@@ -86,7 +86,7 @@ static VOID *pthread_f01(void *argument)
ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT);
#endif
EXIT:
return (void *)9;
return static_cast<void *>(9); // 9: return value for testing
}
static UINT32 Testcase(VOID)
......
......@@ -69,8 +69,9 @@ static UINT32 Testcase(VOID)
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
}
while (g_startNum < THREAD_NUM)
while (g_startNum < THREAD_NUM) {
usleep(1000 * 10 * 2);
}
/*
* Acquire the mutex to make sure that all waiters are currently
......
......@@ -74,8 +74,9 @@ static UINT32 Testcase(VOID)
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
}
while (g_startNum < THREAD_NUM)
while (g_startNum < THREAD_NUM) {
usleep(1000 * 10 * 2);
}
/*
* Acquire the mutex to make sure that all waiters are currently
* blocked on pthread_cond_wait
......
......@@ -81,8 +81,9 @@ static UINT32 Testcase(VOID)
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
}
while (g_startNum < THREAD_NUM)
while (g_startNum < THREAD_NUM) {
usleep(1000 * 10 * 2);
}
/*
* Acquire the mutex to make sure that all waiters are currently
......
......@@ -70,8 +70,9 @@ static UINT32 Testcase(VOID)
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
}
while (g_startNum < THREAD_NUM)
while (g_startNum < THREAD_NUM) {
usleep(1000 * 10 * 2);
}
/*
* Acquire the mutex to make sure that all waiters are currently
......
......@@ -73,8 +73,9 @@ static UINT32 Testcase(VOID)
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
}
while (g_startNum < THREAD_NUM)
while (g_startNum < THREAD_NUM) {
usleep(1000 * 10 * 2);
}
/*
* Acquire the mutex to make sure that all waiters are currently
......
......@@ -68,8 +68,9 @@ static UINT32 Testcase(VOID)
rc = pthread_create(&thread1, NULL, pthread_f01, NULL);
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
while (!g_t1Start) /* wait for thread1 started */
while (!g_t1Start) { /* wait for thread1 started */
usleep(1000 * 10 * 2);
}
/* acquire the mutex released by pthread_cond_wait() within thread 1 */
rc = pthread_mutex_lock(&g_td.mutex);
......
......@@ -57,7 +57,7 @@ static void *pthread_f01(void *arg)
rc = pthread_mutex_unlock(&g_td.mutex);
ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
EXIT:
pthread_exit((void *)5);
pthread_exit(static_cast<void *>(5)); // 5: return value for testing
}
static UINT32 Testcase(VOID)
......@@ -78,9 +78,9 @@ static UINT32 Testcase(VOID)
rc = pthread_create(&thread1, NULL, pthread_f01, NULL);
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
while (!g_t1Start) /* wait for thread1 started */
while (!g_t1Start) { /* wait for thread1 started */
usleep(1000 * 10 * 2);
}
/* acquire the mutex released by pthread_cond_wait() within thread 1 */
rc = pthread_mutex_lock(&g_td.mutex);
......@@ -92,7 +92,7 @@ static UINT32 Testcase(VOID)
g_signaled = 1;
rc = pthread_join(thread1, &thRet);
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
ICUNIT_ASSERT_EQUAL((long)thRet, 5, (long)thRet);
ICUNIT_ASSERT_EQUAL(static_cast<long>(thRet), 5, static_cast<long>(thRet)); // 5: return value for testing
g_signaled = 0;
rc = pthread_cond_destroy(&g_td.cond);
......
......@@ -108,8 +108,9 @@ static void *pthread_f02(void *tmp)
clock_gettime(CLOCK_REALTIME, &startTime);
while (1) {
clock_gettime(CLOCK_REALTIME, &currentTime);
if (PthreadTimeF01(currentTime, startTime) > RUNTIME)
if (PthreadTimeF01(currentTime, startTime) > RUNTIME) {
break;
}
}
g_lowDone = 1;
EXIT:
......
......@@ -111,8 +111,9 @@ static void *pthread_f02(void *tmp)
clock_gettime(CLOCK_REALTIME, &startTime);
while (1) {
clock_gettime(CLOCK_REALTIME, &currentTime);
if (PthreadTimeF01(currentTime, startTime) > RUNTIME)
if (PthreadTimeF01(currentTime, startTime) > RUNTIME) {
break;
}
}
g_lowDone = 1;
EXIT:
......
......@@ -40,8 +40,9 @@ static void *pthread_f01(void *arg)
ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
g_startNum++;
if (g_startNum > 5)
if (g_startNum > 5) { // 5: threshold for calling usleep
usleep(1000 * 10 * 2);
}
printf("pthread start_num: %d \n", g_startNum);
rc = pthread_cond_wait(&g_td.cond, &g_td.mutex);
......
......@@ -48,7 +48,7 @@ static VOID *pthread_f01(void *argument)
ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
EXIT:
return (void *)9;
return reinterpret_cast<void *>(9); // 9: return value for testing
}
static VOID *pthread_f02(void *argument)
......@@ -72,7 +72,7 @@ static VOID *pthread_f02(void *argument)
printf("11\n");
ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // failed , =3
EXIT:
return (void *)9;
return static_cast<void *>(9); // 9: return value for testing
}
static UINT32 Testcase(VOID)
{
......
......@@ -42,8 +42,9 @@ static void *pthread_f01(void *arg)
ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
g_startNum++;
if (g_startNum > 5)
if (g_startNum > 5) { // 5: threshold for calling usleep
usleep(1000 * 10 * 2);
}
printf("pthread start_num: %d \n", g_startNum);
rc = pthread_cond_wait(&g_td.cond, &g_td.mutex);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册