Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
96a45aec
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,发现更多精彩内容 >>
提交
96a45aec
编写于
10月 10, 2022
作者:
C
chengjinsong2
浏览文件
操作
浏览文件
下载
差异文件
Merge branch '1010_API' of
https://gitee.com/chneg-jinsong/startup_init_lite_1
into 1010_API
上级
7cb222a0
76018635
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
27 addition
and
14 deletion
+27
-14
interfaces/innerkits/syspara/param_comm.c
interfaces/innerkits/syspara/param_comm.c
+1
-1
interfaces/kits/jskits/src_v9/native_parameters_js.cpp
interfaces/kits/jskits/src_v9/native_parameters_js.cpp
+20
-7
services/param/base/param_comm.c
services/param/base/param_comm.c
+1
-1
services/param/linux/param_request.c
services/param/linux/param_request.c
+2
-2
services/param/manager/param_manager.c
services/param/manager/param_manager.c
+1
-1
test/unittest/syspara/syspara_unittest.cpp
test/unittest/syspara/syspara_unittest.cpp
+2
-2
未找到文件。
interfaces/innerkits/syspara/param_comm.c
浏览文件 @
96a45aec
...
...
@@ -40,7 +40,7 @@ INIT_LOCAL_API int GetSystemError(int err)
case
PARAM_CODE_INVALID_PARAM
:
case
PARAM_CODE_INVALID_NAME
:
case
PARAM_CODE_READ_ONLY
:
return
SYSPARAM_INVALID_INPUT
;
return
EC_INVALID
;
case
PARAM_CODE_INVALID_VALUE
:
return
SYSPARAM_INVALID_VALUE
;
case
PARAM_CODE_NOT_FOUND
:
...
...
interfaces/kits/jskits/src_v9/native_parameters_js.cpp
浏览文件 @
96a45aec
...
...
@@ -81,6 +81,15 @@ static napi_value BusinessErrorCreate(napi_env env, int status)
return
businessError
;
}
#define PARAM_NAPI_ASSERT(env, assertion, result, info) \
do { \
if (!(assertion)) { \
napi_value d_err = BusinessErrorCreate(env, result); \
napi_throw(env, d_err); \
return nullptr; \
} \
} while (0)
static
int
GetParamString
(
napi_env
env
,
napi_value
arg
,
char
*
buffer
,
size_t
maxBuff
,
size_t
*
keySize
)
{
(
void
)
napi_get_value_string_utf8
(
env
,
arg
,
nullptr
,
maxBuff
-
1
,
keySize
);
...
...
@@ -141,7 +150,8 @@ static napi_value Set(napi_env env, napi_callback_info info)
napi_value
thisVar
=
nullptr
;
void
*
data
=
nullptr
;
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
&
data
);
NAPI_ASSERT
(
env
,
argc
>=
ARGC_NUMBER
,
"requires 2 parameter"
);
PARAM_NAPI_ASSERT
(
env
,
argc
>=
ARGC_NUMBER
,
SYSPARAM_INVALID_INPUT
,
"requires 2 parameter"
);
StorageAsyncContextPtr
asyncContext
=
new
StorageAsyncContext
();
asyncContext
->
env
=
env
;
for
(
size_t
i
=
0
;
i
<
argc
;
i
++
)
{
...
...
@@ -184,12 +194,13 @@ static napi_value SetSync(napi_env env, napi_callback_info info)
size_t
argc
=
ARGC_NUMBER
;
napi_value
args
[
ARGC_NUMBER
]
=
{
nullptr
};
NAPI_CALL
(
env
,
napi_get_cb_info
(
env
,
info
,
&
argc
,
args
,
nullptr
,
nullptr
));
NAPI_ASSERT
(
env
,
argc
==
ARGC_NUMBER
,
"Wrong number of arguments"
);
PARAM_NAPI_ASSERT
(
env
,
argc
==
ARGC_NUMBER
,
SYSPARAM_INVALID_INPUT
,
"Wrong number of arguments"
);
napi_valuetype
valuetype0
=
napi_null
;
NAPI_CALL
(
env
,
napi_typeof
(
env
,
args
[
0
],
&
valuetype0
));
napi_valuetype
valuetype1
=
napi_null
;
NAPI_CALL
(
env
,
napi_typeof
(
env
,
args
[
1
],
&
valuetype1
));
NAPI_ASSERT
(
env
,
valuetype0
==
napi_string
&&
valuetype1
==
napi_string
,
"Wrong argument type. string expected."
);
PARAM_NAPI_ASSERT
(
env
,
valuetype0
==
napi_string
&&
valuetype1
==
napi_string
,
SYSPARAM_INVALID_INPUT
,
"Wrong argument type. string expected."
);
size_t
keySize
=
0
;
std
::
vector
<
char
>
keyBuf
(
MAX_NAME_LENGTH
,
0
);
...
...
@@ -224,14 +235,16 @@ static napi_value GetSync(napi_env env, napi_callback_info info)
size_t
argc
=
ARGC_NUMBER
;
napi_value
args
[
ARGC_NUMBER
]
=
{
nullptr
};
NAPI_CALL
(
env
,
napi_get_cb_info
(
env
,
info
,
&
argc
,
args
,
nullptr
,
nullptr
));
NAPI_ASSERT
(
env
,
argc
==
1
||
argc
==
ARGC_NUMBER
,
"Wrong number of arguments"
);
PARAM_NAPI_ASSERT
(
env
,
argc
==
1
||
argc
==
ARGC_NUMBER
,
SYSPARAM_INVALID_INPUT
,
"Wrong number of arguments"
);
napi_valuetype
valuetype0
=
napi_null
;
NAPI_CALL
(
env
,
napi_typeof
(
env
,
args
[
0
],
&
valuetype0
));
NAPI_ASSERT
(
env
,
valuetype0
==
napi_string
,
"Wrong argument type. Numbers expected."
);
PARAM_NAPI_ASSERT
(
env
,
valuetype0
==
napi_string
,
SYSPARAM_INVALID_INPUT
,
"Wrong argument type. Numbers expected."
);
if
(
argc
==
ARGC_NUMBER
)
{
napi_valuetype
valuetype1
=
napi_null
;
NAPI_CALL
(
env
,
napi_typeof
(
env
,
args
[
1
],
&
valuetype1
));
NAPI_ASSERT
(
env
,
valuetype1
==
napi_string
,
"Wrong argument type. string expected."
);
PARAM_NAPI_ASSERT
(
env
,
valuetype1
==
napi_string
,
SYSPARAM_INVALID_INPUT
,
"Wrong argument type. string expected."
);
}
size_t
keySize
=
0
;
...
...
@@ -320,7 +333,7 @@ static napi_value Get(napi_env env, napi_callback_info info)
napi_value
thisVar
=
nullptr
;
void
*
data
=
nullptr
;
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
&
data
);
NAPI_ASSERT
(
env
,
argc
>=
1
,
"requires 1 parameter"
);
PARAM_NAPI_ASSERT
(
env
,
argc
>=
1
,
SYSPARAM_INVALID_INPUT
,
"requires 1 parameter"
);
StorageAsyncContextPtr
asyncContext
=
new
StorageAsyncContext
();
asyncContext
->
env
=
env
;
for
(
size_t
i
=
0
;
i
<
argc
;
i
++
)
{
...
...
services/param/base/param_comm.c
浏览文件 @
96a45aec
...
...
@@ -516,7 +516,7 @@ INIT_LOCAL_API int ReadParamName(ParamHandle handle, char *name, uint32_t length
PARAM_CHECK
(
name
!=
NULL
,
return
PARAM_CODE_INVALID_PARAM
,
"Invalid param"
);
ParamNode
*
entry
=
(
ParamNode
*
)
GetTrieNodeByHandle
(
handle
);
if
(
entry
==
NULL
)
{
return
-
1
;
return
PARAM_CODE_NOT_FOUND
;
}
PARAM_CHECK
(
length
>
entry
->
keyLength
,
return
-
1
,
"Invalid param size %u %u"
,
entry
->
keyLength
,
length
);
int
ret
=
ParamMemcpy
(
name
,
length
,
entry
->
data
,
entry
->
keyLength
);
...
...
services/param/linux/param_request.c
浏览文件 @
96a45aec
...
...
@@ -174,7 +174,7 @@ int SystemSetParameter(const char *name, const char *value)
g_clientFd
=
GetClientSocket
(
DEFAULT_PARAM_SET_TIMEOUT
);
}
if
(
g_clientFd
<
0
)
{
ret
=
PARAM_CODE_INVALID_PARAM
;
ret
=
DAC_RESULT_FORBIDED
;
break
;
}
ret
=
StartRequest
(
g_clientFd
,
request
,
DEFAULT_PARAM_SET_TIMEOUT
);
...
...
@@ -182,7 +182,7 @@ int SystemSetParameter(const char *name, const char *value)
close
(
g_clientFd
);
g_clientFd
=
INVALID_SOCKET
;
retryCount
++
;
ret
=
0
;
ret
=
DAC_RESULT_FORBIDED
;
}
else
{
break
;
}
...
...
services/param/manager/param_manager.c
浏览文件 @
96a45aec
...
...
@@ -365,7 +365,7 @@ int SystemGetParameterCommitId(ParamHandle handle, uint32_t *commitId)
ParamNode
*
entry
=
(
ParamNode
*
)
GetTrieNodeByHandle
(
handle
);
if
(
entry
==
NULL
)
{
return
-
1
;
return
PARAM_CODE_NOT_FOUND
;
}
*
commitId
=
ReadCommitId
(
entry
);
return
0
;
...
...
test/unittest/syspara/syspara_unittest.cpp
浏览文件 @
96a45aec
...
...
@@ -135,7 +135,7 @@ HWTEST_F(SysparaUnitTest, parameterTest005, TestSize.Level0)
char
value4
[]
=
"rw.sys.version.version.version.version flash_offset = *(hi_u32 *)DT_SetGetU32(&g_Element[0], 0)a\
size = *(hi_u32 *)DT_SetGetU32(&g_Element[1], 0)a"
;
int
ret
=
SetParameter
(
key4
,
value4
);
EXPECT_EQ
(
ret
,
EC_INVALID
);
EXPECT_EQ
(
ret
,
SYSPARAM_INVALID_VALUE
);
}
HWTEST_F
(
SysparaUnitTest
,
parameterTest006
,
TestSize
.
Level0
)
...
...
@@ -171,7 +171,7 @@ HWTEST_F(SysparaUnitTest, parameterTest009, TestSize.Level0)
char
value5
[]
=
"rw.sys.version.version.version.version \
flash_offset = *(hi_u32 *)DT_SetGetU32(&g_Element[0], 0)"
;
int
ret
=
SetParameter
(
key5
,
value5
);
EXPECT_EQ
(
ret
,
EC_INVALID
);
EXPECT_EQ
(
ret
,
SYSPARAM_INVALID_VALUE
);
char
valueGet
[
2
]
=
{
0
};
char
defValue3
[]
=
"value of key > 32 ..."
;
ret
=
GetParameter
(
key5
,
defValue3
,
valueGet
,
2
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录