fix: 内核告警修复

【背景】
内核代码经扫描工具检测发现有可以修改的
告警

【修改方案】
1. 对只有单一语句的if, while等添加括号使之符合编程规范
2. 将C 风格的类型转换变为 C++ 风格的

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

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I0b7659882eec777cade3ee21e76a42a86e2ce822
This commit is contained in:
yinjiaming 2022-09-09 12:00:54 +08:00
parent b8f8ab5a36
commit c237ff63fa
6 changed files with 29 additions and 28 deletions

View File

@ -469,8 +469,9 @@ LWIP_STATIC int OsPingFunc(u32_t *parg)
}
intrvl -= 1000; /* 1000: 1000ms = 1s */
sys_msleep(1000); /* 1000: 1000ms = 1s */
if (ping_kill == 1)
if (ping_kill == 1) {
break;
}
} while (intrvl > 0);
succ_cnt++;
break;

View File

@ -99,7 +99,7 @@ static UINT32 Testcase(VOID)
g_testCount++;
LOS_TaskDelay(2);// 2, set delay time.
LOS_TaskDelay(2); // 2, set delay time.
ICUNIT_GOTO_EQUAL(g_testCount, 7, g_testCount, EXIT1); // 7, Here, assert that g_testCount is equal to 7.

View File

@ -69,7 +69,7 @@ static UINT32 Testcase(VOID)
ret = LOS_TaskCreate(&g_testTaskID01, &task);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
LOS_TaskDelay(100);// 100, set delay time.
LOS_TaskDelay(100); // 100, set delay time.
ICUNIT_GOTO_NOT_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
ICUNIT_TRACK_EQUAL(g_testCount, 1, g_testCount);

View File

@ -55,7 +55,7 @@ static VOID TaskF01(void)
g_testCount++;
LOS_TaskDelay(100);// 100, set delay time.
LOS_TaskDelay(100); // 100, set delay time.
}
static UINT32 Testcase(VOID)
@ -76,7 +76,7 @@ static UINT32 Testcase(VOID)
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
LOS_TaskDelay(1000);// 1000, set delay time.
LOS_TaskDelay(1000); // 1000, set delay time.
ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.

View File

@ -73,8 +73,8 @@ static BOOL PosixMemFuncTestSuiteTearDown(void)
LITE_TEST_CASE(PosixMemFuncTestSuite, testOsMemMemcpy001, Function | MediumTest | Level1)
{
void *retValue = NULL;
char source[]={"This File is About Memony Operation Test , Please Carefully Check Result As Below\r\n"};
char dest[1024]={0};
char source[] = {"This File is About Memony Operation Test , Please Carefully Check Result As Below\r\n"};
char dest[1024] = {0};
retValue = memcpy(dest, source, sizeof(source) / sizeof(source[0]));
TEST_ASSERT_NOT_NULL(retValue);
@ -114,9 +114,9 @@ LITE_TEST_CASE(PosixMemFuncTestSuite, testOsMemMemcpy002, Function | MediumTest
{
void *retValue = NULL;
char source[]={"memory refers to the computer hardware devices used to store information for"
char source[] = {"memory refers to the computer hardware devices used to store information for"
" immediate use in a computer\r\n"};
char dest[1024]={0};
char dest[1024] = {0};
retValue = memcpy(dest, source, sizeof(source) / sizeof(source[0]));
TEST_ASSERT_NOT_NULL(retValue);
@ -155,7 +155,7 @@ LITE_TEST_CASE(PosixMemFuncTestSuite, testOsMemMemcpy002, Function | MediumTest
LITE_TEST_CASE(PosixMemFuncTestSuite, testOsMemMemset001, Function | MediumTest | Level1)
{
void *retValue = NULL;
char source[1024]={"memory refers to the computer hardware devices used to store information for"
char source[1024] = {"memory refers to the computer hardware devices used to store information for"
" immediate use in a computer\r\n"};
char ch = rand() % 26 + 'A';
retValue = memset(source, ch, sizeof(source) / sizeof(source[0]));
@ -177,9 +177,9 @@ LITE_TEST_CASE(PosixMemFuncTestSuite, testOsMemMemset001, Function | MediumTest
LITE_TEST_CASE(PosixMemFuncTestSuite, testOsMemMemcmp001, Function | MediumTest | Level1)
{
int retValue = 0;
char source[]={"memory refers to the computer hardware devices used to store information for "
char source[] = {"memory refers to the computer hardware devices used to store information for "
"immediate use in a computer\r\n"};
char dest[]={"memory refers to the computer hardware devices used to store information for "
char dest[] = {"memory refers to the computer hardware devices used to store information for "
"immediate use in a computer\r\n"};
retValue = memcmp(source, dest, sizeof(source) / sizeof(source[0]));
@ -217,9 +217,9 @@ LITE_TEST_CASE(PosixMemFuncTestSuite, testOsMemMemcmp001, Function | MediumTest
LITE_TEST_CASE(PosixMemFuncTestSuite, testOsMemMemcmp002, Function | MediumTest | Level1)
{
int retValue = 0;
char source[]={"memory refers to the computer hardware devices used to store information for "
char source[] = {"memory refers to the computer hardware devices used to store information for "
"immediate use in a computer\r\n"};
char dest[]={"Hello, Richard, how are you?\r\n"};
char dest[] = {"Hello, Richard, how are you?\r\n"};
retValue = memcmp(source, dest, sizeof(dest) / sizeof(dest[0]));
TEST_ASSERT_GREATER_THAN(0, retValue);
@ -243,8 +243,8 @@ LITE_TEST_CASE(PosixMemFuncTestSuite, testOsMemMemcmp002, Function | MediumTest
LITE_TEST_CASE(PosixMemFuncTestSuite, testOsMemMemcmp003, Function | MediumTest | Level1)
{
int retValue = 0;
char source[]={"00000\r\n"};
char dest[]={"memory refers to the computer hardware devices used to store information for "
char source[] = {"00000\r\n"};
char dest[] = {"memory refers to the computer hardware devices used to store information for "
"immediate use in a computer\r\n"};
retValue = memcmp(source, dest, sizeof(source) / sizeof(source[0]));
TEST_ASSERT_LESS_THAN(0, retValue);

View File

@ -74,8 +74,8 @@ static BOOL PosixStringFuncTestSuiteTearDown(void)
LITE_TEST_CASE(PosixStringFuncTestSuite, testStrstrcmp001, Function | MediumTest | Level1)
{
int retValue = 0;
char source[]={"Compiler exited with error"};
char dest[] ={"Compiler exited with error"};
char source[] = {"Compiler exited with error"};
char dest[] = {"Compiler exited with error"};
retValue = strcmp(source, dest);
TEST_ASSERT_EQUAL_INT(retValue, 0);
@ -98,8 +98,8 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStrstrcmp001, Function | MediumTest
LITE_TEST_CASE(PosixStringFuncTestSuite, testStrstrcmp002, Function | MediumTest | Level1)
{
int retValue = 0;
char source[]={"Compiler exited with error"};
char dest[] ={"00000000000"};
char source[] = {"Compiler exited with error"};
char dest[] = {"00000000000"};
retValue = strcmp(source, dest);
TEST_ASSERT_LESS_THAN(retValue, 0);
@ -115,8 +115,8 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStrstrcmp002, Function | MediumTest
LITE_TEST_CASE(PosixStringFuncTestSuite, testStrstrcmp003, Function | MediumTest | Level1)
{
int retValue = 0;
char source[]={"0000000"};
char dest[] ={"Compiler exited with error"};
char source[] = {"0000000"};
char dest[] = {"Compiler exited with error"};
retValue = strcmp(source, dest);
TEST_ASSERT_GREATER_THAN(retValue, 0);
@ -131,7 +131,7 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStrstrcmp003, Function | MediumTest
*/
LITE_TEST_CASE(PosixStringFuncTestSuite, testStrStrdup001, Function | MediumTest | Level1)
{
char source[]={"Compiler exited with error"};
char source[] = {"Compiler exited with error"};
char *dest;
dest = strdup(source);
@ -158,7 +158,7 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStrStrdup001, Function | MediumTest
*/
LITE_TEST_CASE(PosixStringFuncTestSuite, testStrStrdup002, Function | MediumTest | Level1)
{
char source[]={"export MY_TEST_PATH=/opt/hadoop-2.6.5"};
char source[] = {"export MY_TEST_PATH=/opt/hadoop-2.6.5"};
char *dest;
dest = strdup(source);
@ -177,8 +177,8 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStrStrdup002, Function | MediumTest
LITE_TEST_CASE(PosixStringFuncTestSuite, testStrStrcspn001, Function | MediumTest | Level1)
{
int retValue = 0;
char source[]={"export MY_TEST_PATH=/opt/hadoop-2.6.5"};
char dest1[] ={"H"};
char source[] = {"export MY_TEST_PATH=/opt/hadoop-2.6.5"};
char dest1[] = {"H"};
retValue = strcspn(source, dest1);
TEST_ASSERT_EQUAL_INT(18U, retValue);
@ -202,8 +202,8 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStrStrcspn001, Function | MediumTes
LITE_TEST_CASE(PosixStringFuncTestSuite, testStrStrcspn002, Function | MediumTest | Level1)
{
int retValue = 0;
char source[]={"Compiler exited with error"};
char dest[] ={"or"};
char source[] = {"Compiler exited with error"};
char dest[] = {"or"};
retValue = strcspn(source, dest);
TEST_ASSERT_EQUAL_INT(1, retValue);