diff --git a/interfaces/innerkits/include/service_watcher.h b/interfaces/innerkits/include/service_watcher.h index 3573966a91ddc2ac2811eab364de1b795f513535..bae424886d50250bdbd366489af46016315f6504 100644 --- a/interfaces/innerkits/include/service_watcher.h +++ b/interfaces/innerkits/include/service_watcher.h @@ -28,7 +28,7 @@ extern "C" { #define INVALID_PID 0 -typedef struct serviceInfo_ { +typedef struct { ServiceStatus status; pid_t pid; } ServiceInfo; diff --git a/interfaces/innerkits/reboot/init_reboot_innerkits.c b/interfaces/innerkits/reboot/init_reboot_innerkits.c index daf42b1ee536880388cce7d80def5a0cfc4666a4..6ea77a571a2303fc0900a59b56c51206f664ad93 100644 --- a/interfaces/innerkits/reboot/init_reboot_innerkits.c +++ b/interfaces/innerkits/reboot/init_reboot_innerkits.c @@ -30,7 +30,7 @@ #define DOREBOOT_PARAM "reboot.ut" #endif -static int DoReboot_(const char *mode, const char *option) +static int DoRebootByInitPlugin(const char *mode, const char *option) { char value[MAX_REBOOT_OPTION_SIZE]; int ret = 0; @@ -56,7 +56,7 @@ static int DoReboot_(const char *mode, const char *option) return 0; } -static int ExecReboot_(const char *mode, const char *option) +static int ExecReboot(const char *mode, const char *option) { // check if param set ok #ifndef STARTUP_INIT_TEST @@ -65,7 +65,7 @@ static int ExecReboot_(const char *mode, const char *option) const int maxCount = 1; #endif int count = 0; - DoReboot_(mode, option); + DoRebootByInitPlugin(mode, option); while (count < maxCount) { usleep(100 * 1000); // 100 * 1000 wait 100ms char result[10] = {0}; // 10 stop len @@ -76,7 +76,7 @@ static int ExecReboot_(const char *mode, const char *option) return 0; } count++; - DoReboot_(mode, option); + DoRebootByInitPlugin(mode, option); } BEGET_LOGE("Failed to reboot system"); return 0; @@ -84,10 +84,10 @@ static int ExecReboot_(const char *mode, const char *option) int DoReboot(const char *option) { - return ExecReboot_(NULL, option); + return ExecReboot(NULL, option); } int DoRebootExt(const char *mode, const char *option) { - return ExecReboot_(mode, option); + return ExecReboot(mode, option); } \ No newline at end of file diff --git a/services/modules/sysevent/startup_time_event.c b/services/modules/sysevent/startup_time_event.c index f030dba65cfb7d494a5b233f5fedc9b84769e99f..29619dc92eaf4eec516d51d93df6ee1f6606ceba 100644 --- a/services/modules/sysevent/startup_time_event.c +++ b/services/modules/sysevent/startup_time_event.c @@ -57,7 +57,7 @@ static int TraversalEvent(ListNode *node, void *root) int len = GetServiceName(item->paramName, args->buffer + args->currLen, args->bufferLen - args->currLen); PLUGIN_CHECK(len > 0 && (((uint32_t)len + args->currLen) < args->bufferLen), return -1, "Failed to format service name %s", item->paramName); - args->currLen += len; + args->currLen += (uint32_t)len; len = sprintf_s(args->buffer + args->currLen, args->bufferLen - args->currLen, ",%u:%u,%u:%u;", (uint32_t)item->timestamp[BOOTEVENT_FORK].tv_sec, diff --git a/services/param/manager/param_server.c b/services/param/manager/param_server.c index 87360c2089a8cfef95943a5151bdd496d6dfeb6f..be0cd98f737ff8a9ded6c9fffad2a0998abdecf8 100755 --- a/services/param/manager/param_server.c +++ b/services/param/manager/param_server.c @@ -110,7 +110,7 @@ static void CmdlineIterator(const NAME_VALUE_PAIR *nv, void *context) char fullName[PARAM_NAME_LEN_MAX]; cmdLineIteratorCtx *ctx = (cmdLineIteratorCtx *)context; char *data = (char *)ctx->cmdline; - static const cmdLineInfo cmdLines[] = { + static const cmdLineInfo CMDLINES[] = { { "hardware", CommonDealFun }, { "bootgroup", CommonDealFun }, { "reboot_reason", CommonDealFun }, @@ -131,11 +131,11 @@ static void CmdlineIterator(const NAME_VALUE_PAIR *nv, void *context) } // Matching reserved cmdlines - for (size_t i = 0; i < ARRAY_LENGTH(cmdLines); i++) { + for (size_t i = 0; i < ARRAY_LENGTH(CMDLINES); i++) { // Check exact match - if (strcmp(name, cmdLines[i].name) != 0) { + if (strcmp(name, CMDLINES[i].name) != 0) { // Check if contains ".xxx" for compatibility - ret = snprintf_s(fullName, sizeof(fullName), sizeof(fullName) - 1, ".%s", cmdLines[i].name); + ret = snprintf_s(fullName, sizeof(fullName), sizeof(fullName) - 1, ".%s", CMDLINES[i].name); matched = strstr(name, fullName); if (matched == NULL) { continue; @@ -146,13 +146,13 @@ static void CmdlineIterator(const NAME_VALUE_PAIR *nv, void *context) } } ret = snprintf_s(fullName, sizeof(fullName), sizeof(fullName) - 1, - OHOS_CMDLINE_PARA_PREFIX "%s", cmdLines[i].name); + OHOS_CMDLINE_PARA_PREFIX "%s", CMDLINES[i].name); if (ret <= 0) { continue; } PARAM_LOGV("proc cmdline %s matched.", fullName); - ret = cmdLines[i].processor(fullName, nv->value); - if ((ret == 0) && (SnDealFun == cmdLines[i].processor)) { + ret = CMDLINES[i].processor(fullName, nv->value); + if ((ret == 0) && (SnDealFun == CMDLINES[i].processor)) { ctx->gotSn = true; } return; diff --git a/test/unittest/modules/eng_unittest.cpp b/test/unittest/modules/eng_unittest.cpp index e390ea39cd5e52fb56efe4b8306d5cd289548393..2f06404531ee2e5a988373ac15d528887c373fd5 100644 --- a/test/unittest/modules/eng_unittest.cpp +++ b/test/unittest/modules/eng_unittest.cpp @@ -39,9 +39,9 @@ void BuildMountCmd(char *buffer, size_t len, const char *mp, const char *dev, co bool IsFileExistWithType(const char *file, FileType type); } -static const std::string g_srcFilePath = STARTUP_INIT_UT_PATH"/eng/source/test.txt"; -static const std::string g_targetPath = STARTUP_INIT_UT_PATH"/eng/link_name"; -static const std::string g_engRootPath = STARTUP_INIT_UT_PATH"/eng/"; +static const std::string SRC_FILE_PATH = STARTUP_INIT_UT_PATH"/eng/source/test.txt"; +static const std::string TARGET_PATH = STARTUP_INIT_UT_PATH"/eng/link_name"; +static const std::string ENG_ROOT_PATH = STARTUP_INIT_UT_PATH"/eng/"; static bool RemoveDir(const std::string &path) { @@ -111,37 +111,37 @@ public: HWTEST_F(EngUnitTest, TestFilesOverlay, TestSize.Level1) { bool isDel = false; - bool isExist = IsDirExist(g_engRootPath.c_str()); + bool isExist = IsDirExist(ENG_ROOT_PATH.c_str()); if (isExist) { - isDel = RemoveDir(g_engRootPath.c_str()); + isDel = RemoveDir(ENG_ROOT_PATH.c_str()); EXPECT_EQ(isDel, true); } - isExist = IsDirExist(g_targetPath.c_str()); + isExist = IsDirExist(TARGET_PATH.c_str()); if (isExist) { - isDel = RemoveDir(g_targetPath.c_str()); + isDel = RemoveDir(TARGET_PATH.c_str()); EXPECT_EQ(isDel, true); } - DebugFilesOverlay(g_engRootPath.c_str(), g_targetPath.c_str()); + DebugFilesOverlay(ENG_ROOT_PATH.c_str(), TARGET_PATH.c_str()); - CreateTestFile(g_srcFilePath.c_str(), "test"); - isExist = IsFileExist(g_srcFilePath.c_str()); + CreateTestFile(SRC_FILE_PATH.c_str(), "test"); + isExist = IsFileExist(SRC_FILE_PATH.c_str()); EXPECT_EQ(isExist, true); - DebugFilesOverlay(g_srcFilePath.c_str(), g_targetPath.c_str()); - isExist = IsFileExistWithType(g_srcFilePath.c_str(), TYPE_REG); + DebugFilesOverlay(SRC_FILE_PATH.c_str(), TARGET_PATH.c_str()); + isExist = IsFileExistWithType(SRC_FILE_PATH.c_str(), TYPE_REG); EXPECT_EQ(isExist, true); - if (IsFileExistWithType(g_targetPath.c_str(), TYPE_LINK)) { - if (unlink(g_targetPath.c_str()) < 0) { + if (IsFileExistWithType(TARGET_PATH.c_str(), TYPE_LINK)) { + if (unlink(TARGET_PATH.c_str()) < 0) { EXPECT_TRUE(false); } } - int ret = symlink(g_engRootPath.c_str(), g_targetPath.c_str()); + int ret = symlink(ENG_ROOT_PATH.c_str(), TARGET_PATH.c_str()); EXPECT_EQ(ret, 0); - isExist = IsFileExistWithType(g_targetPath.c_str(), TYPE_LINK); + isExist = IsFileExistWithType(TARGET_PATH.c_str(), TYPE_LINK); EXPECT_EQ(isExist, true); - DebugFilesOverlay(g_targetPath.c_str(), g_engRootPath.c_str()); + DebugFilesOverlay(TARGET_PATH.c_str(), ENG_ROOT_PATH.c_str()); EXPECT_EQ(ret, 0); } @@ -153,38 +153,38 @@ HWTEST_F(EngUnitTest, TestBindMountFile, TestSize.Level1) BindMountFile("/data/init_ut", "/"); bool isExist = false; - if (!IsFileExist(g_srcFilePath.c_str())) { - CreateTestFile(g_srcFilePath.c_str(), "test reg file mount"); - isExist = IsFileExist(g_srcFilePath.c_str()); + if (!IsFileExist(SRC_FILE_PATH.c_str())) { + CreateTestFile(SRC_FILE_PATH.c_str(), "test reg file mount"); + isExist = IsFileExist(SRC_FILE_PATH.c_str()); EXPECT_EQ(isExist, true); - BindMountFile(g_srcFilePath.c_str(), "/"); + BindMountFile(SRC_FILE_PATH.c_str(), "/"); } - if (IsFileExist(g_srcFilePath.c_str())) { + if (IsFileExist(SRC_FILE_PATH.c_str())) { RemoveDir(STARTUP_INIT_UT_PATH"/eng/source"); - isExist = IsFileExist(g_srcFilePath.c_str()); + isExist = IsFileExist(SRC_FILE_PATH.c_str()); EXPECT_EQ(isExist, false); } - if (IsFileExistWithType(g_targetPath.c_str(), TYPE_LINK)) { - if (unlink(g_targetPath.c_str()) < 0) { + if (IsFileExistWithType(TARGET_PATH.c_str(), TYPE_LINK)) { + if (unlink(TARGET_PATH.c_str()) < 0) { EXPECT_TRUE(false); } } - bool isLinkFile = IsFileExist(g_targetPath.c_str()); + bool isLinkFile = IsFileExist(TARGET_PATH.c_str()); EXPECT_EQ(isLinkFile, false); - BindMountFile(g_srcFilePath.c_str(), g_targetPath.c_str()); + BindMountFile(SRC_FILE_PATH.c_str(), TARGET_PATH.c_str()); - int ret = symlink(g_srcFilePath.c_str(), g_targetPath.c_str()); + int ret = symlink(SRC_FILE_PATH.c_str(), TARGET_PATH.c_str()); EXPECT_EQ(ret, 0); - isLinkFile = IsFileExistWithType(g_targetPath.c_str(), TYPE_LINK); + isLinkFile = IsFileExistWithType(TARGET_PATH.c_str(), TYPE_LINK); EXPECT_EQ(isLinkFile, true); - BindMountFile(g_srcFilePath.c_str(), g_targetPath.c_str()); + BindMountFile(SRC_FILE_PATH.c_str(), TARGET_PATH.c_str()); - if (!IsDirExist(g_engRootPath.c_str())) { + if (!IsDirExist(ENG_ROOT_PATH.c_str())) { CheckAndCreateDir(STARTUP_INIT_UT_PATH"/eng/"); } - BindMountFile(g_engRootPath.c_str(), g_targetPath.c_str()); + BindMountFile(ENG_ROOT_PATH.c_str(), TARGET_PATH.c_str()); } HWTEST_F(EngUnitTest, TestMountCmd, TestSize.Level1) @@ -200,14 +200,14 @@ HWTEST_F(EngUnitTest, TestFileType, TestSize.Level1) std::string linkName = "/data/init_ut/eng/link_name_test"; bool isExist = false; - if (!IsFileExist(g_srcFilePath.c_str())) { - CreateTestFile(g_srcFilePath.c_str(), "test"); - isExist = IsFileExist(g_srcFilePath.c_str()); + if (!IsFileExist(SRC_FILE_PATH.c_str())) { + CreateTestFile(SRC_FILE_PATH.c_str(), "test"); + isExist = IsFileExist(SRC_FILE_PATH.c_str()); EXPECT_EQ(isExist, true); } EXPECT_EQ(IsFileExistWithType(STARTUP_INIT_UT_PATH"/eng", TYPE_DIR), true); - EXPECT_EQ(IsFileExistWithType(g_srcFilePath.c_str(), TYPE_REG), true); + EXPECT_EQ(IsFileExistWithType(SRC_FILE_PATH.c_str(), TYPE_REG), true); if (IsFileExist(targetFile)) { if (unlink(targetFile.c_str()) < 0) {