From c237ff63fa500612b244b85364c835c5aeac06a0 Mon Sep 17 00:00:00 2001 From: yinjiaming Date: Fri, 9 Sep 2022 12:00:54 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=86=85=E6=A0=B8=E5=91=8A=E8=AD=A6?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20=E3=80=90=E8=83=8C=E6=99=AF=E3=80=91=20?= =?UTF-8?q?=E5=86=85=E6=A0=B8=E4=BB=A3=E7=A0=81=E7=BB=8F=E6=89=AB=E6=8F=8F?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E6=A3=80=E6=B5=8B=E5=8F=91=E7=8E=B0=E6=9C=89?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E4=BF=AE=E6=94=B9=E7=9A=84=20=E5=91=8A?= =?UTF-8?q?=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【修改方案】 1. 对只有单一语句的if, while等添加括号使之符合编程规范 2. 将C 风格的类型转换变为 C++ 风格的 【影响】 对现有的产品编译不会有影响。 Signed-off-by: yinjiaming Change-Id: I0b7659882eec777cade3ee21e76a42a86e2ce822 --- .../net/lwip-2.1/porting/src/api_shell.c | 3 ++- .../sample/kernel/event/It_los_event_011.c | 2 +- testsuites/sample/kernel/sem/It_los_sem_027.c | 2 +- testsuites/sample/kernel/sem/It_los_sem_034.c | 4 ++-- .../posix/src/string/memory_func_test.c | 22 ++++++++--------- .../posix/src/string/string_func_test_03.c | 24 +++++++++---------- 6 files changed, 29 insertions(+), 28 deletions(-) diff --git a/components/net/lwip-2.1/porting/src/api_shell.c b/components/net/lwip-2.1/porting/src/api_shell.c index 412b64ae..c3b20a8f 100644 --- a/components/net/lwip-2.1/porting/src/api_shell.c +++ b/components/net/lwip-2.1/porting/src/api_shell.c @@ -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; diff --git a/testsuites/sample/kernel/event/It_los_event_011.c b/testsuites/sample/kernel/event/It_los_event_011.c index 21b82cf8..22d9b33c 100644 --- a/testsuites/sample/kernel/event/It_los_event_011.c +++ b/testsuites/sample/kernel/event/It_los_event_011.c @@ -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. diff --git a/testsuites/sample/kernel/sem/It_los_sem_027.c b/testsuites/sample/kernel/sem/It_los_sem_027.c index 7246eac6..eb2ef154 100644 --- a/testsuites/sample/kernel/sem/It_los_sem_027.c +++ b/testsuites/sample/kernel/sem/It_los_sem_027.c @@ -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); diff --git a/testsuites/sample/kernel/sem/It_los_sem_034.c b/testsuites/sample/kernel/sem/It_los_sem_034.c index 53b5303e..71f2e576 100644 --- a/testsuites/sample/kernel/sem/It_los_sem_034.c +++ b/testsuites/sample/kernel/sem/It_los_sem_034.c @@ -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. diff --git a/testsuites/unittest/posix/src/string/memory_func_test.c b/testsuites/unittest/posix/src/string/memory_func_test.c index 4e61647f..8b91873b 100644 --- a/testsuites/unittest/posix/src/string/memory_func_test.c +++ b/testsuites/unittest/posix/src/string/memory_func_test.c @@ -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); diff --git a/testsuites/unittest/posix/src/string/string_func_test_03.c b/testsuites/unittest/posix/src/string/string_func_test_03.c index 0ac8b8fc..12f70473 100644 --- a/testsuites/unittest/posix/src/string/string_func_test_03.c +++ b/testsuites/unittest/posix/src/string/string_func_test_03.c @@ -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);