提交 220326bd 编写于 作者: 4 411148299@qq.com

fix code style

Signed-off-by: N411148299@qq.com <411148299@qq.com>
上级 8bc44fcc
...@@ -16,11 +16,11 @@ ...@@ -16,11 +16,11 @@
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <linux/major.h>
#include <sys/mount.h> #include <sys/mount.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/sysmacros.h> #include <sys/sysmacros.h>
#include <linux/major.h>
#include "init_log.h" #include "init_log.h"
#define DEFAULT_RW_MODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) #define DEFAULT_RW_MODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)
......
...@@ -20,8 +20,8 @@ ...@@ -20,8 +20,8 @@
#include <sys/sysmacros.h> #include <sys/sysmacros.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
#include <linux/major.h>
#include <linux/major.h>
#include "device.h" #include "device.h"
#include "init_log.h" #include "init_log.h"
#include "init_mount.h" #include "init_mount.h"
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include <ctype.h> #include <ctype.h>
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <linux/module.h>
#include <net/if.h> #include <net/if.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdio.h> #include <stdio.h>
...@@ -32,6 +31,7 @@ ...@@ -32,6 +31,7 @@
#include <sys/wait.h> #include <sys/wait.h>
#include <unistd.h> #include <unistd.h>
#include <linux/module.h>
#include "fs_manager/fs_manager.h" #include "fs_manager/fs_manager.h"
#include "init.h" #include "init.h"
#include "init_jobs.h" #include "init_jobs.h"
......
...@@ -50,20 +50,20 @@ static void FreeOldRoot(DIR *dir, dev_t dev) ...@@ -50,20 +50,20 @@ static void FreeOldRoot(DIR *dir, dev_t dev)
if (st.st_dev != dev) { if (st.st_dev != dev) {
continue; // Not the same device, ignore. continue; // Not the same device, ignore.
} }
if (!S_ISDIR(st.st_mode)) {
if (S_ISDIR(st.st_mode)) { continue;
int fd = openat(dfd, de->d_name, O_RDONLY | O_DIRECTORY); }
isDir = true; int fd = openat(dfd, de->d_name, O_RDONLY | O_DIRECTORY);
if (fd < 0) { isDir = true;
continue; if (fd < 0) {
} continue;
DIR *subDir = fdopendir(fd); }
if (subDir != NULL) { DIR *subDir = fdopendir(fd);
FreeOldRoot(subDir, dev); if (subDir != NULL) {
closedir(subDir); FreeOldRoot(subDir, dev);
} else { closedir(subDir);
close(fd); } else {
} close(fd);
} }
} }
if (unlinkat(dfd, de->d_name, isDir ? AT_REMOVEDIR : 0) < 0) { if (unlinkat(dfd, de->d_name, isDir ? AT_REMOVEDIR : 0) < 0) {
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <time.h>
#include "param_manager.h" #include "param_manager.h"
#include "param_utils.h" #include "param_utils.h"
...@@ -112,9 +111,8 @@ static void ExeuteCmdParamRead(int argc, char *argv[], int start) ...@@ -112,9 +111,8 @@ static void ExeuteCmdParamRead(int argc, char *argv[], int start)
SystemSetParameter("test.randrom.test.start", "1"); SystemSetParameter("test.randrom.test.start", "1");
char buffer[PARAM_NAME_LEN_MAX] = {0}; char buffer[PARAM_NAME_LEN_MAX] = {0};
printf("SystemGetParameter start \n"); printf("SystemGetParameter start \n");
(void)srand((unsigned)time(NULL));
while (1) { while (1) {
int wait = rand() / READ_DURATION + READ_DURATION; // 100ms int wait = READ_DURATION + READ_DURATION; // 100ms
uint32_t size = PARAM_NAME_LEN_MAX; uint32_t size = PARAM_NAME_LEN_MAX;
int ret = SystemGetParameter(argv[start], buffer, &size); int ret = SystemGetParameter(argv[start], buffer, &size);
if (ret == 0) { if (ret == 0) {
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
* limitations under the License. * limitations under the License.
*/ */
#include <unistd.h> #include <unistd.h>
#include <time.h>
#include "init_cmds.h" #include "init_cmds.h"
#include "init_param.h" #include "init_param.h"
#include "init_service_manager.h" #include "init_service_manager.h"
...@@ -43,8 +42,7 @@ static void AddTestTrigger(const TriggerWorkSpace *workSpace) ...@@ -43,8 +42,7 @@ static void AddTestTrigger(const TriggerWorkSpace *workSpace)
static void TestTimerCallback(ParamTaskPtr timer, void *context) static void TestTimerCallback(ParamTaskPtr timer, void *context)
{ {
(void)srand((unsigned)time(NULL)); char buffer[32] = { 0 }; // 32 buffer size
char buffer[32] = { 0 };
static int index = 0; static int index = 0;
index++; index++;
if (index >= MAX_COUNT) { if (index >= MAX_COUNT) {
...@@ -53,8 +51,8 @@ static void TestTimerCallback(ParamTaskPtr timer, void *context) ...@@ -53,8 +51,8 @@ static void TestTimerCallback(ParamTaskPtr timer, void *context)
static uint32_t value = 0; static uint32_t value = 0;
int count = 0; int count = 0;
while (count < MAX_COUNT) { while (count < MAX_COUNT) {
int wait = rand() / READ_DURATION + READ_DURATION; // 100ms int wait = READ_DURATION + READ_DURATION; // 100ms
(void)sprintf_s(buffer, sizeof(buffer), "%u", value); sprintf_s(buffer, sizeof(buffer), "%u", value);
PARAM_LOGI("set param name: %s, value %s", TEST_PARAM_NAME, buffer); PARAM_LOGI("set param name: %s, value %s", TEST_PARAM_NAME, buffer);
SystemWriteParam(TEST_PARAM_NAME, buffer); SystemWriteParam(TEST_PARAM_NAME, buffer);
usleep(wait); usleep(wait);
......
...@@ -30,5 +30,4 @@ public: ...@@ -30,5 +30,4 @@ public:
HWTEST_F(ServiceUnitTest, case01, TestSize.Level1) HWTEST_F(ServiceUnitTest, case01, TestSize.Level1)
{ {
} }
} // namespace init_ut } // namespace init_ut
...@@ -212,7 +212,7 @@ void TestClient(int index) ...@@ -212,7 +212,7 @@ void TestClient(int index)
SystemWaitParameter(name.c_str(), nullptr, 0); SystemWaitParameter(name.c_str(), nullptr, 0);
break; break;
} }
case 2: { // 3 api test case 2: { // 2 api test
ParamHandle handle; ParamHandle handle;
uint32_t size = PARAM_BUFFER_SIZE; uint32_t size = PARAM_BUFFER_SIZE;
int ret = SystemFindParameter(name.c_str(), &handle); int ret = SystemFindParameter(name.c_str(), &handle);
......
/* /*
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#include <memory> #include <memory>
#include "init_param.h" #include "init_param.h"
...@@ -59,6 +58,7 @@ public: ...@@ -59,6 +58,7 @@ public:
CheckServerParamValue("const.actionable_compatible_property.enabled", "false"); CheckServerParamValue("const.actionable_compatible_property.enabled", "false");
CheckServerParamValue("build_version", "2.0"); CheckServerParamValue("build_version", "2.0");
CheckServerParamValue("ohos.boot.hardware", "Hi3516DV300"); CheckServerParamValue("ohos.boot.hardware", "Hi3516DV300");
LoadPersistParams();
return 0; return 0;
} }
......
...@@ -51,7 +51,7 @@ public: ...@@ -51,7 +51,7 @@ public:
}; };
using WatcherManagerPtr = WatcherManager *; using WatcherManagerPtr = WatcherManager *;
WatcherManagerPtr g_watcherManager{ nullptr }; WatcherManagerPtr g_watcherManager = nullptr;
class WatcherProxyUnitTest : public ::testing::Test { class WatcherProxyUnitTest : public ::testing::Test {
public: public:
...@@ -72,7 +72,6 @@ public: ...@@ -72,7 +72,6 @@ public:
data.WriteString(keyPrefix); data.WriteString(keyPrefix);
sptr<IWatcher> watcher = new TestWatcher(); sptr<IWatcher> watcher = new TestWatcher();
// std::shared_ptr<TestWatcher> watcher = std::make_shared<TestWatcher>();
bool ret = data.WriteRemoteObject(watcher->AsObject()); bool ret = data.WriteRemoteObject(watcher->AsObject());
WATCHER_CHECK(ret, return 0, "Can not get remote"); WATCHER_CHECK(ret, return 0, "Can not get remote");
watcherManager->OnRemoteRequest(IWatcherManager::ADD_WATCHER, data, reply, option); watcherManager->OnRemoteRequest(IWatcherManager::ADD_WATCHER, data, reply, option);
...@@ -80,7 +79,7 @@ public: ...@@ -80,7 +79,7 @@ public:
EXPECT_NE(watcherId, 0); EXPECT_NE(watcherId, 0);
printf("TestAddWatcher %s watcherId %d %p \n", keyPrefix.c_str(), watcherId, watcherManager); printf("TestAddWatcher %s watcherId %d %p \n", keyPrefix.c_str(), watcherId, watcherManager);
EXPECT_EQ(watcherManager->GetWatcherGroup(1000) != NULL, 0); // test group id EXPECT_EQ(watcherManager->GetWatcherGroup(1000) != NULL, 0); // 1000 test group id
EXPECT_EQ(watcherManager->GetWatcherGroup("TestAddWatcher") != NULL, 0); // test key not exist EXPECT_EQ(watcherManager->GetWatcherGroup("TestAddWatcher") != NULL, 0); // test key not exist
return 0; return 0;
} }
......
mem=640M console=ttyAMA0,115200 mmz=anonymous,0,0xA8000000,384M clk_ignore_unused androidboot.selinux=permissive skip_initramfs rootdelay=10 init = /init root=uuid=aaaaa=/dev/mmcblk0p5 hardware=Hi3516DV300 rootfstype=ext4 ro dddddd=blkdevparts=mmcblk0:1M(boot),15M(kernel),20M(updater),1M(misc),3307M(system),256M(vendor),-(userdata)
\ No newline at end of file
persist.sys.usb.config=hdc
persist.111.ffff.bbbb.cccc.dddd.eeee=1106
persist.111.ffff.bbbb.cccc.dddd.eeee.55555=22202
persist.111.aaaa.bbbb.cccc.dddd.eeee=1102
persist.111.bbbb.cccc.dddd.eeee=1103
persist.111.cccc.bbbb.cccc.dddd.eeee=1104
persist.111.eeee.bbbb.cccc.dddd.eeee=1105
persist.aaaa.aaa=3377
...@@ -146,7 +146,6 @@ void FreeStringVector(char **vector, int count) ...@@ -146,7 +146,6 @@ void FreeStringVector(char **vector, int count)
} }
} }
free(vector); free(vector);
vector = NULL;
} }
} }
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <linux/watchdog.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
...@@ -23,6 +22,8 @@ ...@@ -23,6 +22,8 @@
#include <sys/types.h> #include <sys/types.h>
#include <time.h> #include <time.h>
#include <unistd.h> #include <unistd.h>
#include <linux/watchdog.h>
#include "init_log.h" #include "init_log.h"
#define WAIT_MAX_COUNT 10 #define WAIT_MAX_COUNT 10
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册