提交 be20fbfa 编写于 作者: C chengjinsong

codex

Signed-off-by: Nchengjinsong <chengjinsong2@huawei.com>
上级 c96253d2
......@@ -26,8 +26,8 @@ public:
explicit DeviceInfoProxy(const sptr<IRemoteObject> &impl) : IRemoteProxy<IDeviceInfo>(impl) {}
virtual ~DeviceInfoProxy() {}
virtual int32_t GetUdid(std::string& result) override;
virtual int32_t GetSerialID(std::string& result) override;
int32_t GetUdid(std::string& result) override;
int32_t GetSerialID(std::string& result) override;
private:
static inline BrokerDelegator<DeviceInfoProxy> delegator_;
};
......
......@@ -39,8 +39,8 @@ public:
{
}
~DeviceInfoService() override {}
virtual int32_t GetUdid(std::string& result) override;
virtual int32_t GetSerialID(std::string& result) override;
int32_t GetUdid(std::string& result) override;
int32_t GetSerialID(std::string& result) override;
#ifndef STARTUP_INIT_TEST
protected:
#endif
......
......@@ -348,7 +348,7 @@ int GetBlockDeviceByName(const char *deviceName, const Fstab *fstab, char* miscD
return -1;
}
static const struct MountFlags mountFlags[] = {
static const struct MountFlags MOUNT_FLAGS[] = {
{ "noatime", MS_NOATIME },
{ "noexec", MS_NOEXEC },
{ "nosuid", MS_NOSUID },
......@@ -372,8 +372,8 @@ static bool IsDefaultMountFlags(const char *str)
bool isDefault = false;
if (str != NULL) {
for (size_t i = 0; i < ARRAY_LENGTH(mountFlags); i++) {
if (strcmp(str, mountFlags[i].name) == 0) {
for (size_t i = 0; i < ARRAY_LENGTH(MOUNT_FLAGS); i++) {
if (strcmp(str, MOUNT_FLAGS[i].name) == 0) {
isDefault = true;
}
}
......@@ -386,9 +386,9 @@ static unsigned long ParseDefaultMountFlag(const char *str)
unsigned long flags = 0;
if (str != NULL) {
for (size_t i = 0; i < ARRAY_LENGTH(mountFlags); i++) {
if (strcmp(str, mountFlags[i].name) == 0) {
flags = mountFlags[i].flags;
for (size_t i = 0; i < ARRAY_LENGTH(MOUNT_FLAGS); i++) {
if (strcmp(str, MOUNT_FLAGS[i].name) == 0) {
flags = MOUNT_FLAGS[i].flags;
break;
}
}
......
......@@ -68,7 +68,7 @@ struct SandboxMountFlags {
unsigned long value;
};
static const struct SandboxMountFlags g_flags[] = {
static const struct SandboxMountFlags FLAGS[] = {
{
.flag = "bind",
.value = MS_BIND,
......@@ -99,7 +99,7 @@ struct SandboxMap {
const char *configfile;
};
static const struct SandboxMap g_map[] = {
static const struct SandboxMap MAP[] = {
{
.name = "system",
.sandbox = &g_systemSandbox,
......@@ -124,9 +124,9 @@ static unsigned long GetSandboxMountFlags(cJSON *item)
BEGET_ERROR_CHECK(item != NULL, return 0, "Invalid parameter.");
char *str = cJSON_GetStringValue(item);
BEGET_CHECK(str != NULL, return 0);
for (size_t i = 0; i < ARRAY_LENGTH(g_flags); i++) {
if (strcmp(str, g_flags[i].flag) == 0) {
return g_flags[i].value;
for (size_t i = 0; i < ARRAY_LENGTH(FLAGS); i++) {
if (strcmp(str, FLAGS[i].flag) == 0) {
return FLAGS[i].value;
}
}
return 0;
......@@ -260,10 +260,10 @@ static int ParseSandboxConfig(cJSON *root, sandbox_t *sandbox)
static const struct SandboxMap *GetSandboxMapByName(const char *name)
{
BEGET_ERROR_CHECK(name != NULL, return NULL, "Sandbox map name is NULL.");
int len = ARRAY_LENGTH(g_map);
int len = ARRAY_LENGTH(MAP);
for (int i = 0; i < len; i++) {
if (strcmp(g_map[i].name, name) == 0) {
return &g_map[i];
if (strcmp(MAP[i].name, name) == 0) {
return &MAP[i];
}
}
return NULL;
......
......@@ -202,8 +202,7 @@ static napi_value GetSync(napi_env env, napi_callback_info info)
napi_value napiValue = nullptr;
if (ret == 0) {
const char *value = getValue.c_str();
NAPI_CALL(env, napi_create_string_utf8(env, value, strlen(value), &napiValue));
NAPI_CALL(env, napi_create_string_utf8(env, getValue.c_str(), strlen(getValue.c_str()), &napiValue));
}
return napiValue;
}
......
......@@ -20,7 +20,7 @@ import argparse
import os
import sys
def DecodeCfgLine(data):
def decode_cfg_line(data):
data.replace('\n', '').replace('\r', '')
data = data.strip()
if (len(data) == 0 or data[0] == '#'):
......@@ -30,46 +30,46 @@ def DecodeCfgLine(data):
return "", ""
return strs[0].strip(), strs[1].strip()
def GetParamFromCfg(cfgName):
def get_param_from_cfg(cfg_name):
dict = {}
with open(cfgName) as afile:
with open(cfg_name) as afile:
data = afile.readline()
while data:
name, value = DecodeCfgLine(data)
name, value = decode_cfg_line(data)
if len(name) != 0 and len(value) != 0:
dict[name] = value
print("sample file name={%s %s}"%(name, value))
data = afile.readline()
return dict
def DecodeCodeLine(data):
def decode_code_line(data):
data.replace('\n', '').replace('\r', '')
data = data.strip()
if (not data.startswith("PARAM_MAP")):
return "", ""
dataLen = len(data)
data = data[len("PARAM_MAP") + 1 : dataLen - 1]
data_len = len(data)
data = data[len("PARAM_MAP") + 1 : data_len - 1]
data = data.strip()
strs = data.split(',')
if len(strs) <= 1:
return "", ""
return strs[0].strip(), data[len(strs[0]) + 1: ].strip()
def GetParamFromCCode(codeName):
def get_param_from_c_code(code_name):
dict = {}
with open(codeName, "r+") as afile:
with open(code_name, "r+") as afile:
data = afile.readline()
while data:
name, value = DecodeCodeLine(data)
name, value = decode_code_line(data)
if len(name) != 0 and len(value) != 0:
dict[name] = value
data = afile.readline()
afile.truncate(0)
return dict
def WriteMapToCode(codeName, dict):
def write_map_to_code(code_name, dict):
try:
with open(codeName, "w") as f:
with open(code_name, "w") as f:
# start with 0
f.seek(0)
# write file header
......@@ -110,18 +110,18 @@ def WriteMapToCode(codeName, dict):
f.write(os.linesep)
f.truncate()
except IOError:
print("Error: open or write file %s fail"%{codeName})
print("Error: open or write file %s fail"%{code_name})
return 0
def AddToCodeDict(codeDict, cfgDict, high = True):
for name, value in cfgDict.items():
def add_to_code_dict(code_dict, cfg_dict, high = True):
for name, value in cfg_dict.items():
# check if name exit
hasKey = name in codeDict #codeDict.has_key(name)
if hasKey and high:
codeDict[name] = value
elif not hasKey:
codeDict[name] = value
return codeDict
has_key = name in code_dict #code_dict.has_key(name)
if has_key and high:
code_dict[name] = value
elif not has_key:
code_dict[name] = value
return code_dict
def main():
parser = argparse.ArgumentParser(
......@@ -146,16 +146,16 @@ def main():
print("source {}".format(out_dir))
assert os.path.exists(source)
srcDict = GetParamFromCfg(source)
src_dict = get_param_from_cfg(source)
dst = "".join([out_dir, "param_cfg.h"])
if os.path.exists(dst):
dstDict = GetParamFromCCode(dst)
dst_dict = get_param_from_c_code(dst)
else:
dstDict = {}
dst_dict = {}
dstDict = AddToCodeDict(dstDict, srcDict, False)
WriteMapToCode(dst, dstDict)
dst_dict = add_to_code_dict(dst_dict, src_dict, False)
write_map_to_code(dst, dst_dict)
return 0
......
......@@ -206,7 +206,7 @@ static void WriteLogoToMisc(const std::string &logoPath)
static int main_cmd(BShellHandle shell, int argc, char **argv)
{
if (argc >= 2 && strcmp((char *)"--write_logo", argv[0]) == 0) { // 2 min arg
if (argc >= 2 && strcmp(const_cast<char *>("--write_logo"), argv[0]) == 0) { // 2 min arg
WriteLogoToMisc(argv[1]);
} else {
char *helpArgs[] = {const_cast<char *>("misc_daemon"), nullptr};
......
......@@ -74,7 +74,7 @@ static void RunSandbox(const std::string &sandboxName)
static void EnterShell()
{
char *argv[] = { (char *)"sh", NULL };
char *argv[] = { const_cast<char *>("sh"), NULL };
char *envp[] = { nullptr };
if (execve("/system/bin/sh", argv, envp) != 0) {
std::cout << "execve sh failed! err = "<< errno << std::endl;
......
......@@ -18,7 +18,8 @@ import os
import sys
import json
sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, os.pardir, os.pardir, os.pardir, os.pardir, "build"))
sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir,
os.pardir, os.pardir, os.pardir, os.pardir, "build"))
from scripts.util import build_utils # noqa: E402
def parse_args(args):
......@@ -39,7 +40,7 @@ def parse_params(line, contents):
if pos <= 0:
return
name = line[:pos]
value = line[pos+1:]
value = line[pos + 1:]
name = name.strip()
value = value.strip()
contents[name] = value
......
......@@ -478,6 +478,17 @@ static void CheckServiceSocket(Service *service)
return;
}
static void CheckOndemandService(service)
{
CheckServiceSocket(service);
if (strcmp(service->name, "console") == 0) {
if (WatchConsoleDevice(service) < 0) {
INIT_LOGE("Failed to watch console service after it exit, mark console service invalid");
service->attribute |= SERVICE_ATTR_INVALID;
}
}
}
void ServiceReap(Service *service)
{
INIT_CHECK(service != NULL, return);
......@@ -530,13 +541,7 @@ void ServiceReap(Service *service)
}
// service no need to restart if it is an ondemand service.
if (IsOnDemandService(service)) {
CheckServiceSocket(service);
if (strcmp(service->name, "console") == 0) {
if (WatchConsoleDevice(service) < 0) {
INIT_LOGE("Failed to watch console service after it exit, mark console service invalid");
service->attribute |= SERVICE_ATTR_INVALID;
}
}
CheckOndemandService(service);
return;
}
......
......@@ -1018,8 +1018,7 @@ void ParseAllServices(const cJSON *fileRoot)
// Watch "/dev/console" node for starting console service ondemand.
if ((strcmp(service->name, "console") == 0) && IsOnDemandService(service)) {
if (WatchConsoleDevice(service) < 0) {
INIT_LOGW("Failed to watch \'/dev/console\' device");
INIT_LOGW("Remove service \' %s \' ondemand attribute", service->name);
INIT_LOGW("Failed to watch console device, unset \' %s \' ondemand attribute", service->name);
UnMarkServiceAsOndemand(service);
}
}
......
......@@ -13,11 +13,11 @@
* limitations under the License.
*/
#ifndef _MODULE_REBOOT_ADP_H
#define _MODULE_REBOOT_ADP_H
#ifndef MODULE_REBOOT_ADP_H
#define MODULE_REBOOT_ADP_H
#include <stdio.h>
int GetRebootReasonFromMisc(char *reason, size_t size);
int UpdateMiscMessage(const char *valueData, const char *cmd, const char *cmdExt, const char *boot);
#endif /* _MODULE_REBOOT_ADP_H */
#endif /* MODULE_REBOOT_ADP_H */
......@@ -303,7 +303,7 @@ class GenBpfPolicy:
@staticmethod
def gen_bpf_ge32(const_str, jt, jf):
bpf_policy = []
bpf_policy.append(BPF_JGE.format(const_str+' & 0xffffffff', jt, jf))
bpf_policy.append(BPF_JGE.format(const_str + ' & 0xffffffff', jt, jf))
return bpf_policy
@staticmethod
......@@ -315,12 +315,12 @@ class GenBpfPolicy:
low = number & 0xffffffff
if digit_flag and hight == 0:
bpf_policy.append(BPF_JGT.format('((unsigned long)'+const_str+') >> 32', jt + 2, 0))
bpf_policy.append(BPF_JGT.format('((unsigned long)' + const_str + ') >> 32', jt + 2, 0))
else:
bpf_policy.append(BPF_JGT.format('((unsigned long)'+const_str+') >> 32', jt + 3, 0))
bpf_policy.append(BPF_JEQ.format('((unsigned long)'+const_str+') >> 32', 0, jf + 2))
bpf_policy.append(BPF_JGT.format('((unsigned long)' + const_str + ') >> 32', jt + 3, 0))
bpf_policy.append(BPF_JEQ.format('((unsigned long)' + const_str + ') >> 32', 0, jf + 2))
bpf_policy.append(BPF_LOAD_MEM.format(0))
bpf_policy.append(BPF_JGE.format(const_str+' & 0xffffffff', jt, jf))
bpf_policy.append(BPF_JGE.format(const_str + ' & 0xffffffff', jt, jf))
return bpf_policy
def gen_bpf_ge(self, const_str, jt, jf):
......@@ -342,7 +342,7 @@ class GenBpfPolicy:
@staticmethod
def gen_bpf_set64(const_str, jt, jf):
bpf_policy = []
bpf_policy.append(BPF_JSET.format('((unsigned long)' + const_str+') >> 32', jt + 2, 0))
bpf_policy.append(BPF_JSET.format('((unsigned long)' + const_str + ') >> 32', jt + 2, 0))
bpf_policy.append(BPF_LOAD_MEM.format(0))
bpf_policy.append(BPF_JSET.format(const_str + ' & 0xffffffff', jt, jf))
return bpf_policy
......
......@@ -13,11 +13,11 @@
* limitations under the License.
*/
#ifndef _PLUGIN_SELINUX_ADP_H
#define _PLUGIN_SELINUX_ADP_H
#ifndef PLUGIN_SELINUX_ADP_H
#define PLUGIN_SELINUX_ADP_H
# define SECON_STR_IN_CFG ("secon")
// https://github.com/xelerance/Openswan/blob/86dff2b/include/pluto/state.h#L222
# define MAX_SECON_LEN (257)
#endif /* _PLUGIN_SELINUX_ADP_H */
#endif /* PLUGIN_SELINUX_ADP_H */
......@@ -205,7 +205,7 @@ void WatcherManagerKits::ParamWatcher::OnParameterChange(const std::string &name
WATCHER_LOGI("OnParameterChange name %s value %s", name.c_str(), value.c_str());
uint32_t index = 0;
ParameterChangeListener *listener = GetParameterListener(&index);
while (listener != NULL) {
while (listener != nullptr) {
if (!listener->CheckValueChange(value)) {
listener->OnParameterChange(name, value);
}
......@@ -240,7 +240,7 @@ int WatcherManagerKits::ParamWatcher::DelParameterListener(ParameterChangePtr ca
{
uint32_t index = 0;
ParameterChangeListener *listener = GetParameterListener(&index);
while (listener != NULL) {
while (listener != nullptr) {
if ((callback == nullptr && context == nullptr)) {
RemoveParameterListener(index);
} else if (listener->IsEqual(callback, context)) {
......
......@@ -66,7 +66,7 @@ private:
class ParamWatcher final : public Watcher {
public:
explicit ParamWatcher(const std::string &key) : keyPrefix_(key) {}
virtual ~ParamWatcher()
~ParamWatcher() override
{
parameterChangeListeners.clear();
};
......
......@@ -236,7 +236,7 @@ void WatcherManager::SendLocalChange(const std::string &keyPrefix, ParamWatcherP
SystemGetParameterValue(handle, context->buffer + PARAM_NAME_LEN_MAX, &size);
WATCHER_LOGV("SendLocalChange key %s value: %s ", context->buffer, context->buffer + PARAM_NAME_LEN_MAX);
context->watcher->ProcessParameterChange(context->buffer, context->buffer + PARAM_NAME_LEN_MAX);
}, (void *)&context);
}, reinterpret_cast<void *>(&context));
}
void WatcherManager::RunLoop()
......
......@@ -38,7 +38,7 @@ HWTEST_F(BegetctlUnitTest, TestShellInit, TestSize.Level0)
const char *args[] = {
"param"
};
BShellEnvDirectExecute(GetShellHandle(), 1, (char **)args);
BShellEnvDirectExecute(GetShellHandle(), 1, const_cast<char **>(args));
}
HWTEST_F(BegetctlUnitTest, TestShellLs, TestSize.Level1)
......@@ -47,7 +47,7 @@ HWTEST_F(BegetctlUnitTest, TestShellLs, TestSize.Level1)
const char *args[] = {
"param", "ls"
};
BShellEnvDirectExecute(GetShellHandle(), sizeof(args) / sizeof(args[0]), (char **)args);
BShellEnvDirectExecute(GetShellHandle(), sizeof(args) / sizeof(args[0]), const_cast<char **>(args));
}
HWTEST_F(BegetctlUnitTest, TestShellLsWithR, TestSize.Level1)
......@@ -56,7 +56,7 @@ HWTEST_F(BegetctlUnitTest, TestShellLsWithR, TestSize.Level1)
const char *args[] = {
"param", "ls", "-r"
};
BShellEnvDirectExecute(GetShellHandle(), sizeof(args) / sizeof(args[0]), (char **)args);
BShellEnvDirectExecute(GetShellHandle(), sizeof(args) / sizeof(args[0]), const_cast<char **>(args));
}
HWTEST_F(BegetctlUnitTest, TestShellLsGet, TestSize.Level1)
......@@ -65,7 +65,7 @@ HWTEST_F(BegetctlUnitTest, TestShellLsGet, TestSize.Level1)
const char *args[] = {
"param", "get"
};
BShellEnvDirectExecute(GetShellHandle(), sizeof(args) / sizeof(args[0]), (char **)args);
BShellEnvDirectExecute(GetShellHandle(), sizeof(args) / sizeof(args[0]), const_cast<char **>(args));
}
HWTEST_F(BegetctlUnitTest, TestShellSet, TestSize.Level1)
......@@ -74,7 +74,7 @@ HWTEST_F(BegetctlUnitTest, TestShellSet, TestSize.Level1)
const char *args[] = {
"param", "set", "aaaaa", "1234567"
};
BShellEnvDirectExecute(GetShellHandle(), sizeof(args) / sizeof(args[0]), (char **)args);
BShellEnvDirectExecute(GetShellHandle(), sizeof(args) / sizeof(args[0]), const_cast<char **>(args));
}
HWTEST_F(BegetctlUnitTest, TestShellGetWithKey, TestSize.Level1)
......@@ -83,7 +83,7 @@ HWTEST_F(BegetctlUnitTest, TestShellGetWithKey, TestSize.Level1)
const char *args[] = {
"param", "get", "aaaaa"
};
BShellEnvDirectExecute(GetShellHandle(), sizeof(args) / sizeof(args[0]), (char **)args);
BShellEnvDirectExecute(GetShellHandle(), sizeof(args) / sizeof(args[0]), const_cast<char **>(args));
}
HWTEST_F(BegetctlUnitTest, TestShellWait, TestSize.Level1)
......@@ -92,7 +92,7 @@ HWTEST_F(BegetctlUnitTest, TestShellWait, TestSize.Level1)
const char *args[] = {
"param", "wait", "aaaaa"
};
BShellEnvDirectExecute(GetShellHandle(), sizeof(args) / sizeof(args[0]), (char **)args);
BShellEnvDirectExecute(GetShellHandle(), sizeof(args) / sizeof(args[0]), const_cast<char **>(args));
}
HWTEST_F(BegetctlUnitTest, TestShellWaitFalse, TestSize.Level1)
{
......@@ -100,7 +100,7 @@ HWTEST_F(BegetctlUnitTest, TestShellWaitFalse, TestSize.Level1)
const char *args[] = {
"param", "wait"
};
BShellEnvDirectExecute(GetShellHandle(), sizeof(args) / sizeof(args[0]), (char **)args);
BShellEnvDirectExecute(GetShellHandle(), sizeof(args) / sizeof(args[0]), const_cast<char **>(args));
}
HWTEST_F(BegetctlUnitTest, TestShellWaitWithKey, TestSize.Level1)
......@@ -109,7 +109,7 @@ HWTEST_F(BegetctlUnitTest, TestShellWaitWithKey, TestSize.Level1)
const char *args[] = {
"param", "wait", "aaaaa", "12*", "30"
};
BShellEnvDirectExecute(GetShellHandle(), sizeof(args) / sizeof(args[0]), (char **)args);
BShellEnvDirectExecute(GetShellHandle(), sizeof(args) / sizeof(args[0]), const_cast<char **>(args));
}
HWTEST_F(BegetctlUnitTest, TestShellParamShell, TestSize.Level1)
{
......@@ -117,7 +117,7 @@ HWTEST_F(BegetctlUnitTest, TestShellParamShell, TestSize.Level1)
const char *args[] = {
"param", "shell"
};
BShellEnvDirectExecute(GetShellHandle(), sizeof(args) / sizeof(args[0]), (char **)args);
BShellEnvDirectExecute(GetShellHandle(), sizeof(args) / sizeof(args[0]), const_cast<char **>(args));
}
HWTEST_F(BegetctlUnitTest, TestShellLsWithvalue, TestSize.Level1)
{
......@@ -126,7 +126,7 @@ HWTEST_F(BegetctlUnitTest, TestShellLsWithvalue, TestSize.Level1)
const char *args[] = {
"param", "ls", PARAM_REVERESD_NAME_CURR_PARAMETER
};
BShellEnvDirectExecute(GetShellHandle(), sizeof(args) / sizeof(args[0]), (char **)args);
BShellEnvDirectExecute(GetShellHandle(), sizeof(args) / sizeof(args[0]), const_cast<char **>(args));
}
HWTEST_F(BegetctlUnitTest, TestShellLsWithvalueExist, TestSize.Level1)
{
......@@ -135,6 +135,6 @@ HWTEST_F(BegetctlUnitTest, TestShellLsWithvalueExist, TestSize.Level1)
const char *args[] = {
"param", "ls", "-r", PARAM_REVERESD_NAME_CURR_PARAMETER
};
BShellEnvDirectExecute(GetShellHandle(), sizeof(args) / sizeof(args[0]), (char **)args);
BShellEnvDirectExecute(GetShellHandle(), sizeof(args) / sizeof(args[0]), const_cast<char **>(args));
}
} // namespace init_ut
......@@ -43,14 +43,14 @@ static int TestHashNodeCompare(const HashNode *node1, const HashNode *node2)
static int TestHashKeyCompare(const HashNode *node1, const void *key)
{
TestHashNode *testNode1 = HASHMAP_ENTRY(node1, TestHashNode, node);
return strcmp(testNode1->name, (char *)key);
return strcmp(testNode1->name, reinterpret_cast<char *>(const_cast<void *>(key)));
}
static int TestHashNodeFunction(const HashNode *node)
{
TestHashNode *testNode = HASHMAP_ENTRY(node, TestHashNode, node);
int code = 0;
for (int i = 0; i < (int)strlen(testNode->name); i++) {
for (size_t i = 0; i < strlen(testNode->name); i++) {
code += testNode->name[i] - 'A';
}
return code;
......@@ -60,7 +60,7 @@ static int TestHashKeyFunction(const void *key)
{
int code = 0;
char *buff = const_cast<char *>(static_cast<const char *>(key));
for (int i = 0; i < (int)strlen(buff); i++) {
for (size_t i = 0; i < strlen(buff); i++) {
code += buff[i] - 'A';
}
return code;
......
......@@ -74,10 +74,12 @@ static void TestForMultiThread()
"thread.5555.1111.2222.3333.4444"
};
for (size_t i = 0; i < threadMaxNumer; i++) {
pthread_create(&tids[i], nullptr, TestSendParamSetMsg, (void *)names[i % ARRAY_LENGTH(names)]);
pthread_create(&tids[i], nullptr, TestSendParamSetMsg,
reinterpret_cast<void *>(const_cast<char *>(names[i % ARRAY_LENGTH(names)])));
}
for (size_t i = threadMaxNumer; i < threadMaxNumer + threadMaxNumer; i++) {
pthread_create(&tids[i], nullptr, TestSendParamWaitMsg, (void *)names[i % ARRAY_LENGTH(names)]);
pthread_create(&tids[i], nullptr, TestSendParamWaitMsg,
reinterpret_cast<void *>(const_cast<char *>(names[i % ARRAY_LENGTH(names)])));
}
for (size_t i = 0; i < threadMaxNumer + threadMaxNumer; i++) {
pthread_join(tids[i], nullptr);
......
......@@ -90,7 +90,7 @@ public:
int cmdKeyIndex = 0;
const char *matchCmd = GetMatchCmd("setparam aaaa aaaa", &cmdKeyIndex);
printf("cmd %d \n", matchCmd != nullptr);
EXPECT_EQ(matchCmd != 0, 1);
EXPECT_NE(matchCmd, nullptr);
ReadConfig();
ParseInitCfg(STARTUP_INIT_UT_PATH "/trigger_test.cfg");
......
......@@ -133,11 +133,10 @@ typedef struct {
#define DEV_NODE_PATH_PREFIX "/dev/"
#define DEV_NODE_PATH_PREFIX_LEN 5
static const DYNAMIC_DEVICE_NODE dynamicDevices[] = {
static const DYNAMIC_DEVICE_NODE DYNAMIC_DEVICES[] = {
{ DEV_NODE_PATH_PREFIX"tty", S_IFCHR | DEFAULT_RW_MODE },
{ DEV_NODE_PATH_PREFIX"binder", S_IFCHR | DEFAULT_RW_MODE },
{ DEV_NODE_PATH_PREFIX"console", S_IFCHR | DEFAULT_RW_MODE },
{ DEV_NODE_PATH_PREFIX"tty", S_IFCHR | DEFAULT_RW_MODE }
{ DEV_NODE_PATH_PREFIX"console", S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP }
};
static void HandleRequiredDynamicDeviceNodes(const struct Uevent *uevent)
......@@ -149,17 +148,17 @@ static void HandleRequiredDynamicDeviceNodes(const struct Uevent *uevent)
return;
}
while (idx < sizeof(dynamicDevices)/sizeof(dynamicDevices[0])) {
if (strcmp(uevent->deviceName, dynamicDevices[idx].dev + DEV_NODE_PATH_PREFIX_LEN) != 0) {
while (idx < sizeof(DYNAMIC_DEVICES)/sizeof(DYNAMIC_DEVICES[0])) {
if (strcmp(uevent->deviceName, DYNAMIC_DEVICES[idx].dev + DEV_NODE_PATH_PREFIX_LEN) != 0) {
idx++;
continue;
}
// Matched
mask = umask(0);
if (mknod(dynamicDevices[idx].dev, dynamicDevices[idx].mode,
if (mknod(DYNAMIC_DEVICES[idx].dev, DYNAMIC_DEVICES[idx].mode,
makedev(uevent->major, uevent->minor)) != 0) {
INIT_LOGE("Create device node %s failed. %s", dynamicDevices[idx].dev, strerror(errno));
INIT_LOGE("Create device node %s failed. %s", DYNAMIC_DEVICES[idx].dev, strerror(errno));
}
// Restore umask
umask(mask);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册