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

@@ -51,8 +51,8 @@ static int SleepTest(int64_t expectTime)
ret = clock_gettime(clk, &oldtp);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
tp.tv_sec = expectTime / (long)1e9;
tp.tv_nsec = expectTime % (long)1e9;
tp.tv_sec = expectTime / static_cast<long>(1e9);
tp.tv_nsec = expectTime % static_cast<long>(1e9);
ret = clock_nanosleep(clk, 0, &tp, nullptr);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
@@ -60,7 +60,7 @@ static int SleepTest(int64_t expectTime)
ret = clock_gettime(clk, &tp);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
escapeTime = (tp.tv_sec - oldtp.tv_sec) * (int64_t)1e9 + (tp.tv_nsec - oldtp.tv_nsec);
escapeTime = (tp.tv_sec - oldtp.tv_sec) * static_cast<int64_t>(1e9) + (tp.tv_nsec - oldtp.tv_nsec);
LogPrintln("slept time (expected --> actual): %" PRId64 "ns --> %" PRId64 "ns, delta: %" PRId64 "ns\n", expectTime,
escapeTime, escapeTime - expectTime);