fix: 内核告警修复

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

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

【影响】
对现有的产品编译不会有影响。

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I7d4a04a8904abb3c33e843049bf15f4386d3efd8
This commit is contained in:
yinjiaming
2022-09-09 11:50:48 +08:00
parent 71e51d8813
commit 96b2d557ac
155 changed files with 532 additions and 460 deletions

View File

@@ -94,8 +94,9 @@ static int SetTimerTest(void)
ret = clock_gettime(CLOCKID, &end);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
expected = its.it_value.tv_sec * (int64_t)1e9 + its.it_value.tv_nsec;
escaped = end.tv_sec * (int64_t)1e9 + end.tv_nsec - start.tv_sec * (int64_t)1e9 - start.tv_nsec;
expected = its.it_value.tv_sec * static_cast<int64_t>(1e9) + its.it_value.tv_nsec;
escaped = end.tv_sec * static_cast<int64_t>(1e9) + end.tv_nsec - start.tv_sec * static_cast<int64_t>(1e9) -
start.tv_nsec;
failed += (escaped < expected || (escaped - expected) >= 20000000); // 20000000, 2 ticks.
}

View File

@@ -52,7 +52,7 @@ static void SigHandler(int sig, siginfo_t *si, void *uc)
#ifdef TEST_ON_LINUX
timer_t timerid = *(timer_t *)si->si_value.sival_ptr;
#else // SA_SIGINFO not compatible with POSIX on HMOS
timer_t timerid = *(timer_t *)si;
timer_t timerid = *reinterpret_cast<timer_t *>(si);
#endif
g_tmrOverrun += timer_getoverrun(timerid);

View File

@@ -69,7 +69,7 @@ static int TimerTest(void)
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
sev.sigev_notify = SIGEV_THREAD;
sev.sigev_notify_function = TempSigHandler;
sev.sigev_value.sival_ptr = (void *)TempSigHandler01;
sev.sigev_value.sival_ptr = reinterpret_cast<void *>(TempSigHandler01);
/* Start the timer */
its.it_value.tv_sec = 3; // 3, timer time 3 seconds.
@@ -89,7 +89,7 @@ static int TimerTest(void)
its.it_interval.tv_sec = its.it_value.tv_sec;
its.it_interval.tv_nsec = its.it_value.tv_nsec;
sev.sigev_value.sival_ptr = (void *)TempSigHandler02;
sev.sigev_value.sival_ptr = reinterpret_cast<void *>(TempSigHandler02);
ret = timer_create(CLOCK_REALTIME, &sev, &timerid02);
LogPrintln("timer_settime %p: %d", timerid02, ret);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);

View File

@@ -42,7 +42,7 @@ static UINT32 testcase(VOID)
int ret = 0;
errno = 0;
ret = putenv((char *) "TZ=GMT-100");
ret = putenv(const_cast<char *>("TZ=GMT-100"));
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
tzset();