Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
2e4db6ee
S
Startup Init Lite
项目概览
OpenHarmony
/
Startup Init Lite
大约 1 年 前同步成功
通知
3
Star
37
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Startup Init Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
2e4db6ee
编写于
8月 23, 2022
作者:
O
openharmony_ci
提交者:
Gitee
8月 23, 2022
浏览文件
操作
浏览文件
下载
差异文件
!1109 修复代码静态检查(0822)
Merge pull request !1109 from cheng_jinsong/codex
上级
6e1ae8b7
93e0c848
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
57 addition
and
54 deletion
+57
-54
interfaces/innerkits/fs_manager/fstab_mount.c
interfaces/innerkits/fs_manager/fstab_mount.c
+4
-1
scripts/param_cfg_to_code.py
scripts/param_cfg_to_code.py
+43
-45
services/begetctl/dump_service.c
services/begetctl/dump_service.c
+2
-1
services/begetctl/partitionslot.cpp
services/begetctl/partitionslot.cpp
+1
-1
services/etc/param/param_fixer.py
services/etc/param/param_fixer.py
+1
-1
services/param/linux/param_message.c
services/param/linux/param_message.c
+1
-1
test/unittest/seccomp/seccomp_unittest.cpp
test/unittest/seccomp/seccomp_unittest.cpp
+2
-2
test/unittest/tools/prepare_testdata.sh
test/unittest/tools/prepare_testdata.sh
+3
-2
未找到文件。
interfaces/innerkits/fs_manager/fstab_mount.c
浏览文件 @
2e4db6ee
...
...
@@ -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
);
...
...
scripts/param_cfg_to_code.py
浏览文件 @
2e4db6ee
...
...
@@ -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
)
...
...
services/begetctl/dump_service.c
浏览文件 @
2e4db6ee
...
...
@@ -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
{
...
...
services/begetctl/partitionslot.cpp
浏览文件 @
2e4db6ee
...
...
@@ -19,7 +19,7 @@
#include "v1_0/ipartition_slot.h"
using
namespace
OHOS
::
HDI
::
Partitionslot
::
V1_0
;
const
int32_t
PARTITION_ARGC
=
2
;
static
const
int32_t
PARTITION_ARGC
=
2
;
static
int
GetSlot
(
BShellHandle
handle
,
int32_t
argc
,
char
*
argv
[])
{
...
...
services/etc/param/param_fixer.py
浏览文件 @
2e4db6ee
...
...
@@ -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
)
...
...
services/param/linux/param_message.c
浏览文件 @
2e4db6ee
...
...
@@ -33,7 +33,7 @@ int ConnectServer(int fd, const char *servername)
addr
.
sun_family
=
AF_UNIX
;
ret
=
sprintf_s
(
addr
.
sun_path
,
sizeof
(
addr
.
sun_path
)
-
1
,
"%s"
,
servername
);
PARAM_CHECK
(
ret
>
EOK
,
return
-
1
,
"Failed to sprintf_s server address"
);
s
ize
_t
len
=
offsetof
(
struct
sockaddr_un
,
sun_path
)
+
strlen
(
addr
.
sun_path
);
s
ocklen
_t
len
=
offsetof
(
struct
sockaddr_un
,
sun_path
)
+
strlen
(
addr
.
sun_path
);
ret
=
connect
(
fd
,
(
struct
sockaddr
*
)
&
addr
,
len
);
PARAM_CHECK
(
ret
!=
-
1
,
return
-
1
,
"Failed to connect server %s %d"
,
servername
,
errno
);
PARAM_LOGV
(
"ConnectServer %s success"
,
servername
);
...
...
test/unittest/seccomp/seccomp_unittest.cpp
浏览文件 @
2e4db6ee
...
...
@@ -57,7 +57,7 @@ public:
{
pid_t
pid
=
fork
();
if
(
pid
==
0
)
{
if
(
prctl
(
PR_SET_NO_NEW_PRIVS
,
1
,
0
,
0
,
0
))
{
if
(
prctl
(
PR_SET_NO_NEW_PRIVS
,
1
,
0
,
0
,
0
)
!=
0
)
{
std
::
cout
<<
"PR_SET_NO_NEW_PRIVS set fail "
<<
std
::
endl
;
exit
(
EXIT_FAILURE
);
}
...
...
@@ -115,7 +115,7 @@ public:
return
-
1
;
}
if
(
flag
)
{
if
(
flag
!=
0
)
{
std
::
cout
<<
"Child process time out"
<<
std
::
endl
;
}
...
...
test/unittest/tools/prepare_testdata.sh
浏览文件 @
2e4db6ee
#!
/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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录