From 80a2ad370c554ad3f3147940d66c8a440b480224 Mon Sep 17 00:00:00 2001 From: chengjinsong2 Date: Tue, 4 Jul 2023 11:27:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BC=96=E8=AF=91=E5=91=8A?= =?UTF-8?q?=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chengjinsong2 --- services/loopevent/loop/le_epoll.c | 3 +-- services/modules/init_eng/init_eng.c | 1 - services/utils/init_utils.c | 13 +++++++------ .../fuzztest/DoFormat_fuzzer/DoFormat_fuzzer.cpp | 2 -- .../GetMountStatusForMountPoint_fuzzer.cpp | 1 - .../IsSupportedFilesystem_fuzzer.cpp | 1 - .../LoadFscryptPolicy_fuzzer.cpp | 1 - test/unittest/deviceinfo/DeviceInfoUnittest.cpp | 2 +- test/unittest/loopevent/loopserver_unittest.cpp | 16 +++++++++------- test/unittest/param/param_shell_unittest.cpp | 1 - test/unittest/param/param_stub.h | 2 +- 11 files changed, 19 insertions(+), 24 deletions(-) diff --git a/services/loopevent/loop/le_epoll.c b/services/loopevent/loop/le_epoll.c index a47134de..947695e3 100644 --- a/services/loopevent/loop/le_epoll.c +++ b/services/loopevent/loop/le_epoll.c @@ -16,7 +16,6 @@ #include #include "le_epoll.h" -#include "le_utils.h" static int IsValid_(const EventEpoll *loop) { @@ -139,4 +138,4 @@ LE_STATUS CreateEpollLoop(EventLoop **loop, uint32_t maxevents, uint32_t timeout epoll->loop.addEvent = AddEvent_; epoll->loop.modEvent = ModEvent_; return LE_SUCCESS; -} \ No newline at end of file +} diff --git a/services/modules/init_eng/init_eng.c b/services/modules/init_eng/init_eng.c index 9b365963..921c43d3 100644 --- a/services/modules/init_eng/init_eng.c +++ b/services/modules/init_eng/init_eng.c @@ -72,7 +72,6 @@ ENG_STATIC void BuildMountCmd(char *buffer, size_t len, const char *mp, const ch { int ret = snprintf_s(buffer, len, len - 1, "%s %s %s ro barrier=1", fstype, dev, mp); - if (ret == -1) { *buffer = '\0'; } diff --git a/services/utils/init_utils.c b/services/utils/init_utils.c index d1e54591..7d05fda0 100644 --- a/services/utils/init_utils.c +++ b/services/utils/init_utils.c @@ -206,6 +206,7 @@ int IterateNameValuePairs(const char *src, void (*iterator)(const NAME_VALUE_PAI { int cnt = 0; const char *seperator; + const char *tmp = src; NAME_VALUE_PAIR nv; if ((src == NULL) || (iterator == NULL)) { return -1; @@ -213,15 +214,15 @@ int IterateNameValuePairs(const char *src, void (*iterator)(const NAME_VALUE_PAI do { // Find space seperator - nv.name = src; - seperator = strchr(src, ' '); + nv.name = tmp; + seperator = strchr(tmp, ' '); if (seperator == NULL) { // Last nv - nv.valueEnd = src + strlen(src); - src = NULL; + nv.valueEnd = tmp + strlen(tmp); + tmp = NULL; } else { nv.valueEnd = seperator; - src = seperator + 1; + tmp = seperator + 1; } // Find equal seperator @@ -239,7 +240,7 @@ int IterateNameValuePairs(const char *src, void (*iterator)(const NAME_VALUE_PAI iterator(&nv, context); cnt += 1; - } while (src != NULL); + } while (tmp != NULL); return cnt; } diff --git a/test/fuzztest/DoFormat_fuzzer/DoFormat_fuzzer.cpp b/test/fuzztest/DoFormat_fuzzer/DoFormat_fuzzer.cpp index e52f02de..745b7d4b 100644 --- a/test/fuzztest/DoFormat_fuzzer/DoFormat_fuzzer.cpp +++ b/test/fuzztest/DoFormat_fuzzer/DoFormat_fuzzer.cpp @@ -13,8 +13,6 @@ * limitations under the License. */ -#include "DoFormat_fuzzer.h" -#include #include #include "fs_manager/fs_manager.h" diff --git a/test/fuzztest/GetMountStatusForMountPoint_fuzzer/GetMountStatusForMountPoint_fuzzer.cpp b/test/fuzztest/GetMountStatusForMountPoint_fuzzer/GetMountStatusForMountPoint_fuzzer.cpp index 93d783c1..e627188f 100644 --- a/test/fuzztest/GetMountStatusForMountPoint_fuzzer/GetMountStatusForMountPoint_fuzzer.cpp +++ b/test/fuzztest/GetMountStatusForMountPoint_fuzzer/GetMountStatusForMountPoint_fuzzer.cpp @@ -14,7 +14,6 @@ */ #include "GetMountStatusForMountPoint_fuzzer.h" -#include #include #include "fs_manager/fs_manager.h" diff --git a/test/fuzztest/IsSupportedFilesystem_fuzzer/IsSupportedFilesystem_fuzzer.cpp b/test/fuzztest/IsSupportedFilesystem_fuzzer/IsSupportedFilesystem_fuzzer.cpp index 07ddd54f..900d944d 100644 --- a/test/fuzztest/IsSupportedFilesystem_fuzzer/IsSupportedFilesystem_fuzzer.cpp +++ b/test/fuzztest/IsSupportedFilesystem_fuzzer/IsSupportedFilesystem_fuzzer.cpp @@ -14,7 +14,6 @@ */ #include "IsSupportedFilesystem_fuzzer.h" -#include #include #include "fs_manager/fs_manager.h" diff --git a/test/fuzztest/LoadFscryptPolicy_fuzzer/LoadFscryptPolicy_fuzzer.cpp b/test/fuzztest/LoadFscryptPolicy_fuzzer/LoadFscryptPolicy_fuzzer.cpp index 50d2f10c..c5a5334a 100644 --- a/test/fuzztest/LoadFscryptPolicy_fuzzer/LoadFscryptPolicy_fuzzer.cpp +++ b/test/fuzztest/LoadFscryptPolicy_fuzzer/LoadFscryptPolicy_fuzzer.cpp @@ -14,7 +14,6 @@ */ #include "LoadFscryptPolicy_fuzzer.h" -#include #include "fs_manager/fs_manager.h" namespace OHOS { diff --git a/test/unittest/deviceinfo/DeviceInfoUnittest.cpp b/test/unittest/deviceinfo/DeviceInfoUnittest.cpp index 114c232a..7fe745df 100644 --- a/test/unittest/deviceinfo/DeviceInfoUnittest.cpp +++ b/test/unittest/deviceinfo/DeviceInfoUnittest.cpp @@ -36,7 +36,7 @@ using namespace testing::ext; using namespace std; using namespace OHOS; -int g_tokenType = OHOS::Security::AccessToken::TOKEN_HAP; +static int g_tokenType = OHOS::Security::AccessToken::TOKEN_HAP; int g_tokenVerifyResult = 0; namespace OHOS { namespace Security { diff --git a/test/unittest/loopevent/loopserver_unittest.cpp b/test/unittest/loopevent/loopserver_unittest.cpp index d44779d5..d43d0173 100644 --- a/test/unittest/loopevent/loopserver_unittest.cpp +++ b/test/unittest/loopevent/loopserver_unittest.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include "begetctl.h" #include "cJSON.h" @@ -62,7 +63,8 @@ static void DecodeMessage(const char *buffer, size_t nread, uint32_t &cmd) return; } -static void SendMessage(const LoopHandle loopHandle, const TaskHandle taskHandle, const char *message, ...) +template +static void SendMessage(const LoopHandle loopHandle, const TaskHandle taskHandle, const char *message, Args... args) { uint32_t bufferSize = 1024; // 1024 buffer size BufferHandle handle = LE_CreateBuffer(loopHandle, bufferSize); @@ -96,21 +98,21 @@ static void TestOnReceiveRequest(const TaskHandle task, const uint8_t *buffer, u if (buffer == nullptr) { return; } - printf("Server receive message %s \n", reinterpret_cast(buffer)); + printf("Server receive message %s \n", static_cast(buffer)); uint32_t cmd = 0; - DecodeMessage(reinterpret_cast(buffer), nread, cmd); - SendMessage(g_loopServer_, task, reinterpret_cast(buffer)); + DecodeMessage(static_cast(buffer), nread, cmd); + SendMessage(g_loopServer_, task, static_cast(buffer)); } static void TestClientOnReceiveRequest(const TaskHandle task, const uint8_t *buffer, uint32_t nread) { - printf("Client receive message %s \n", reinterpret_cast(buffer)); + printf("Client receive message %s \n", static_cast(buffer)); EXPECT_NE(buffer, nullptr); if (buffer == nullptr) { return; } uint32_t cmd = 0; - DecodeMessage(reinterpret_cast(buffer), nread, cmd); + DecodeMessage(static_cast(buffer), nread, cmd); if (cmd == 5 || cmd == 2) { // 2 5 close server LE_StopLoop(g_loopClient_); } @@ -130,7 +132,7 @@ static void TestSendMessageComplete(const TaskHandle taskHandle, BufferHandle ha uint32_t bufferSize = 1024; // 1024 buffer size char *buffer = (char *)LE_GetBufferInfo(handle, nullptr, &bufferSize); uint32_t cmd = 0; - DecodeMessage(reinterpret_cast(buffer), bufferSize, cmd); + DecodeMessage(static_cast(buffer), bufferSize, cmd); if (cmd == 5) { // 5 close server LE_StopLoop(g_loopServer_); } diff --git a/test/unittest/param/param_shell_unittest.cpp b/test/unittest/param/param_shell_unittest.cpp index bf0af31c..35afb7ee 100644 --- a/test/unittest/param/param_shell_unittest.cpp +++ b/test/unittest/param/param_shell_unittest.cpp @@ -213,6 +213,5 @@ HWTEST_F(ParamShellUnitTest, TestParamShellcmd2, TestSize.Level1) BShellEnvLoop(nullptr); BShellEnvErrString(GetShellHandle(), 1); BShellEnvOutputResult(GetShellHandle(), 1); - } } // namespace init_ut diff --git a/test/unittest/param/param_stub.h b/test/unittest/param/param_stub.h index 59dd3eac..8c7817ca 100644 --- a/test/unittest/param/param_stub.h +++ b/test/unittest/param/param_stub.h @@ -76,4 +76,4 @@ ParamLabelIndex *TestGetParamLabelIndex(const char *name); } #endif #endif -#endif // PARAM_TEST_STUB_ \ No newline at end of file +#endif // PARAM_TEST_STUB_ -- GitLab