提交 93e0c848 编写于 作者: C chengjinsong

codex

Signed-off-by: Nchengjinsong <chengjinsong2@huawei.com>
上级 c9fc516d
......@@ -316,7 +316,10 @@ static int GetSlotInfoFromMisc(off_t offset, off_t size)
char miscDev[MAX_BUFFER_LEN] = {0};
BEGET_ERROR_CHECK(GetBlockDevicePath("/misc", miscDev, MAX_BUFFER_LEN) == 0,
return -1, "Failed to get misc device");
int fd = open(miscDev, O_RDWR | O_CLOEXEC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
char *realPath = GetRealPath(miscDev);
BEGET_ERROR_CHECK(realPath != NULL, return -1, "Failed to get misc device real path");
int fd = open(realPath, O_RDWR | O_CLOEXEC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
free(realPath);
BEGET_ERROR_CHECK(fd >= 0, return -1, "Failed to open misc device, errno %d", errno);
BEGET_ERROR_CHECK(lseek(fd, offset, SEEK_SET) >= 0, close(fd); return -1,
"Failed to lseek misc device fd, errno %d", errno);
......
......@@ -69,50 +69,48 @@ def GetParamFromCCode(codeName):
def WriteMapToCode(codeName, dict):
try:
f = open(codeName, 'w')
# start with 0
f.seek(0)
# write file header
f.write('#ifndef PARAM_LITE_DEF_CFG_' + os.linesep)
f.write('#define PARAM_LITE_DEF_CFG_' + os.linesep)
f.write('#include <stdint.h>' + os.linesep + os.linesep)
f.write('#ifdef __cplusplus' + os.linesep)
f.write('#if __cplusplus' + os.linesep)
f.write('extern "C" {' + os.linesep)
f.write('#endif' + os.linesep)
f.write('#endif' + os.linesep + os.linesep)
#define struct
f.write('typedef struct Node_ {' + os.linesep)
f.write(' const char *name;' + os.linesep)
f.write(' const char *value;' + os.linesep)
f.write('} Node;' + os.linesep + os.linesep)
f.write('#define PARAM_MAP(name, value) {(const char *)#name, (const char *)#value},')
f.write(os.linesep + os.linesep)
# write data
f.write('static Node g_paramDefCfgNodes[] = {' + os.linesep)
for name, value in dict.items():
if (value.startswith("\"")):
str = " PARAM_MAP({0}, {1})".format(name, value)
f.write(str + os.linesep)
else:
str = " PARAM_MAP({0}, \"{1}\")".format(name, value)
f.write(str + os.linesep)
f.write('};' + os.linesep + os.linesep)
#end
f.write('#ifdef __cplusplus' + os.linesep)
f.write('#if __cplusplus' + os.linesep)
f.write('}' + os.linesep)
f.write('#endif' + os.linesep)
f.write('#endif' + os.linesep)
f.write('#endif // PARAM_LITE_DEF_CFG_' + os.linesep)
f.write(os.linesep)
f.truncate()
with open(codeName, "w") as f:
# start with 0
f.seek(0)
# write file header
f.write('#ifndef PARAM_LITE_DEF_CFG_' + os.linesep)
f.write('#define PARAM_LITE_DEF_CFG_' + os.linesep)
f.write('#include <stdint.h>' + os.linesep + os.linesep)
f.write('#ifdef __cplusplus' + os.linesep)
f.write('#if __cplusplus' + os.linesep)
f.write('extern "C" {' + os.linesep)
f.write('#endif' + os.linesep)
f.write('#endif' + os.linesep + os.linesep)
#define struct
f.write('typedef struct Node_ {' + os.linesep)
f.write(' const char *name;' + os.linesep)
f.write(' const char *value;' + os.linesep)
f.write('} Node;' + os.linesep + os.linesep)
f.write('#define PARAM_MAP(name, value) {(const char *)#name, (const char *)#value},')
f.write(os.linesep + os.linesep)
# write data
f.write('static Node g_paramDefCfgNodes[] = {' + os.linesep)
for name, value in dict.items():
if (value.startswith("\"")):
str = " PARAM_MAP({0}, {1})".format(name, value)
f.write(str + os.linesep)
else:
str = " PARAM_MAP({0}, \"{1}\")".format(name, value)
f.write(str + os.linesep)
f.write('};' + os.linesep + os.linesep)
#end
f.write('#ifdef __cplusplus' + os.linesep)
f.write('#if __cplusplus' + os.linesep)
f.write('}' + os.linesep)
f.write('#endif' + os.linesep)
f.write('#endif' + os.linesep)
f.write('#endif // PARAM_LITE_DEF_CFG_' + os.linesep)
f.write(os.linesep)
f.truncate()
except IOError:
print("Error: open or write file %s fail"%{codeName})
else:
f.close()
return 0
def AddToCodeDict(codeDict, cfgDict, high = True):
......@@ -142,14 +140,14 @@ def main():
out_dir = args.dest_dir
if not os.path.exists(out_dir):
os.makedirs(out_dir, exist_ok=True)
print("out_dir " + out_dir)
print("out_dir {}".format(out_dir))
for source in args.source:
print("source " + source)
print("source {}".format(out_dir))
assert os.path.exists(source)
srcDict = GetParamFromCfg(source)
dst = out_dir + "param_cfg.h"
dst = "".join([out_dir, "param_cfg.h"])
if os.path.exists(dst):
dstDict = GetParamFromCCode(dst)
......
......@@ -33,8 +33,9 @@ static int main_cmd(BShellHandle shell, int argc, char **argv)
printf("dump service bootevent info \n");
size_t serviceNameLen = strlen(argv[1]) + strlen(argv[2]) + 2; // 2 is \0 and #
char *serviceBootevent = (char *)calloc(1, serviceNameLen);
BEGET_ERROR_CHECK(serviceBootevent != NULL, return 0, "failed to allocate bootevent memory");
BEGET_ERROR_CHECK(sprintf_s(serviceBootevent, serviceNameLen, "%s#%s", argv[1], argv[2]) >= 0,
return 0, "dumpservice arg create failed");
free(serviceBootevent); return 0, "dumpservice arg create failed");
CmdClientInit(INIT_CONTROL_FD_SOCKET_PATH, ACTION_DUMP, serviceBootevent);
free(serviceBootevent);
} else {
......
......@@ -67,7 +67,7 @@ def fix_para_file(options):
with open(options.output, 'w') as f:
for key in contents:
f.write(key + "=" + contents[key] + '\n')
f.write("".join([key, "=", contents[key], '\n']))
def main(args):
options = parse_args(args)
......
#! /bin/bash
#!/bin/bash
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
......@@ -16,6 +16,7 @@
# Usage:
# ./prepare_testdata.sh path
# path is the rootdir of ohos projects.
set -e
if [ $# -lt 1 ];then
echo "Usage $0 <product name>"
......@@ -111,7 +112,7 @@ if [ $? -ne 0 ]; then
exit 1
fi
if [ ! -f ${ohos_init}/g.sh ]; then
if [ ! -f "${ohos_init}/g.sh" ]; then
echo "create g.sh"
touch ${ohos_init}/g.sh
echo "${ohos_root}/prebuilts/clang/ohos/linux-x86_64/llvm/bin/llvm-cov gcov \$@" > ${ohos_init}/g.sh
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册