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
@@ -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);
@@ -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);