提交 63da7430 编写于 作者: C chengjinsong2

修改函数BUG

Signed-off-by: Nchengjinsong2 <chengjinsong2@huawei.com>
上级 3c168e3e
......@@ -322,10 +322,12 @@ const char *GetBuildRootHash(void)
int32_t GetIntParameter(const char *key, int32_t def)
{
char value[MAX_INT_LEN] = {0};
int ret = GetParameter(key, "0", value, sizeof(value));
if (ret < 0) {
size_t size = sizeof(value);
int ret = SystemGetParameter(key, value, &size);
if (ret != 0) {
return def;
}
long long int result = 0;
if (StringToLL(value, &result) != 0) {
return def;
......@@ -339,10 +341,12 @@ int32_t GetIntParameter(const char *key, int32_t def)
uint32_t GetUintParameter(const char *key, uint32_t def)
{
char value[MAX_INT_LEN] = {0};
int ret = GetParameter(key, "0", value, sizeof(value));
if (ret < 0) {
size_t size = sizeof(value);
int ret = SystemGetParameter(key, value, &size);
if (ret != 0) {
return def;
}
unsigned long long int result = 0;
if (StringToULL(value, &result) != 0) {
return def;
......
......@@ -282,6 +282,8 @@ HWTEST_F(SysparaUnitTest, parameterTest0013, TestSize.Level0)
EXPECT_EQ(GetUintParameter("test.int.get", 0), 0);
EXPECT_EQ(GetIntParameter("test.uint.get", 0), TEST_VALUE);
EXPECT_EQ(GetUintParameter("test.uint.get", 0), TEST_VALUE);
EXPECT_EQ(GetIntParameter("test.int.default", 10), 10); //key not find,value = default
EXPECT_EQ(GetUintParameter("test.uint.default", 10), 10); //key not find,value = default
EXPECT_EQ(IsValidParamValue(nullptr, 0), 0);
EXPECT_EQ(IsValidParamValue("testvalue", strlen("testvalue") + 1), 1);
EXPECT_EQ(StringToLL("0x11", &out), 0);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册