Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Utils Native Lite
提交
a9ca4df5
U
Utils Native Lite
项目概览
OpenHarmony
/
Utils Native Lite
大约 1 年 前同步成功
通知
2
Star
19
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
Utils Native Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a9ca4df5
编写于
9月 16, 2020
作者:
G
Gymee
提交者:
Gitee
9月 16, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
tweaks code for optimization
上级
de54ae53
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
25 addition
and
41 deletion
+25
-41
kal/timer/src/kal.c
kal/timer/src/kal.c
+2
-5
kv_store/src/kvstore_impl_hal/kv_store.c
kv_store/src/kvstore_impl_hal/kv_store.c
+14
-22
kv_store/src/kvstore_impl_posix/kv_store.c
kv_store/src/kvstore_impl_posix/kv_store.c
+9
-14
未找到文件。
kal/timer/src/kal.c
浏览文件 @
a9ca4df5
...
...
@@ -143,12 +143,9 @@ KalErrCode KalTimerDelete(KalTimerId timerId)
}
KalTimer
*
tmpPtr
=
(
KalTimer
*
)
timerId
;
int
ret
=
timer_delete
(
tmpPtr
->
timerPtr
);
if
(
ret
!=
0
)
{
free
(
timerId
);
return
KAL_ERR_INNER
;
}
free
(
timerId
);
return
KAL_OK
;
timerId
=
NULL
;
return
(
ret
!=
0
)
?
KAL_ERR_INNER
:
KAL_OK
;
}
unsigned
int
KalTimerIsRunning
(
KalTimerId
timerId
)
...
...
kv_store/src/kvstore_impl_hal/kv_store.c
浏览文件 @
a9ca4df5
...
...
@@ -40,11 +40,12 @@ static int GetValueByFile(const char* key, char* value, unsigned int len)
if
(
fd
<
0
)
{
return
EC_FAILURE
;
}
if
(
UtilsFileRead
(
fd
,
value
,
valueLen
)
<
0
)
{
UtilsFileClose
(
fd
);
int
ret
=
UtilsFileRead
(
fd
,
value
,
valueLen
);
UtilsFileClose
(
fd
);
fd
=
-
1
;
if
(
ret
<
0
)
{
return
EC_FAILURE
;
}
UtilsFileClose
(
fd
);
value
[
valueLen
]
=
'\0'
;
return
valueLen
;
}
...
...
@@ -55,12 +56,10 @@ static int SetValueToFile(const char* key, const char* value)
if
(
fd
<
0
)
{
return
EC_FAILURE
;
}
if
(
UtilsFileWrite
(
fd
,
value
,
strlen
(
value
))
<
0
)
{
UtilsFileClose
(
fd
);
return
EC_FAILURE
;
}
int
ret
=
UtilsFileWrite
(
fd
,
value
,
strlen
(
value
));
UtilsFileClose
(
fd
);
return
EC_SUCCESS
;
fd
=
-
1
;
return
(
ret
<
0
)
?
EC_FAILURE
:
EC_SUCCESS
;
}
static
int
GetCurrentItem
(
void
)
...
...
@@ -70,13 +69,10 @@ static int GetCurrentItem(void)
return
0
;
}
char
value
[
KV_SUM_INDEX
]
=
{
0
};
if
(
UtilsFileRead
(
fd
,
value
,
KV_SUM_INDEX
)
<
0
)
{
UtilsFileClose
(
fd
);
return
0
;
}
int
ret
=
UtilsFileRead
(
fd
,
value
,
KV_SUM_INDEX
);
UtilsFileClose
(
fd
);
int
sum
=
atoi
(
value
)
;
return
sum
;
fd
=
-
1
;
return
(
ret
<
0
)
?
0
:
atoi
(
value
)
;
}
static
int
SetCurrentItem
(
const
int
num
)
...
...
@@ -89,12 +85,10 @@ static int SetCurrentItem(const int num)
if
(
fd
<
0
)
{
return
EC_FAILURE
;
}
if
(
UtilsFileWrite
(
fd
,
value
,
KV_SUM_INDEX
)
<
0
)
{
UtilsFileClose
(
fd
);
return
EC_FAILURE
;
}
int
ret
=
UtilsFileWrite
(
fd
,
value
,
KV_SUM_INDEX
);
UtilsFileClose
(
fd
);
return
EC_SUCCESS
;
fd
=
-
1
;
return
(
ret
<
0
)
?
EC_FAILURE
:
EC_SUCCESS
;
}
static
boolean
NewItem
(
const
char
*
key
)
...
...
@@ -159,10 +153,8 @@ int UtilsDeleteValue(const char* key)
DeleteKVCache
(
key
);
#endif
int
ret
=
UtilsFileDelete
(
key
);
int
currentNum
=
GetCurrentItem
();
if
(
ret
==
EC_SUCCESS
)
{
currentNum
--
;
ret
=
SetCurrentItem
(
currentNum
);
ret
=
SetCurrentItem
(
GetCurrentItem
()
-
1
);
}
return
ret
;
}
...
...
kv_store/src/kvstore_impl_posix/kv_store.c
浏览文件 @
a9ca4df5
...
...
@@ -86,12 +86,12 @@ static int GetValueByFile(const char* dataPath, const char* key, char* value, un
if
(
fd
<
0
)
{
return
EC_FAILURE
;
}
if
(
read
(
fd
,
value
,
info
.
st_size
)
<
0
)
{
close
(
fd
);
return
EC_FAILURE
;
}
int
ret
=
read
(
fd
,
value
,
info
.
st_size
);
close
(
fd
);
fd
=
-
1
;
if
(
ret
<
0
)
{
return
EC_FAILURE
;
}
value
[
info
.
st_size
]
=
'\0'
;
return
info
.
st_size
;
}
...
...
@@ -112,12 +112,10 @@ static int SetValueToFile(const char* dataPath, const char* key, const char* val
if
(
fd
<
0
)
{
return
EC_FAILURE
;
}
if
(
write
(
fd
,
value
,
strlen
(
value
))
<
0
)
{
close
(
fd
);
return
EC_FAILURE
;
}
int
ret
=
write
(
fd
,
value
,
strlen
(
value
));
close
(
fd
);
return
EC_SUCCESS
;
fd
=
-
1
;
return
(
ret
<
0
)
?
EC_FAILURE
:
EC_SUCCESS
;
}
static
int
DeleteValueFromFile
(
const
char
*
dataPath
,
const
char
*
key
)
...
...
@@ -317,10 +315,7 @@ int UtilsSetEnv(const char* path)
return
EC_FAILURE
;
}
pthread_mutex_lock
(
&
g_kvGlobalMutex
);
if
(
strcpy_s
(
g_dataPath
,
MAX_KEY_PATH
+
1
,
path
)
!=
EOK
)
{
pthread_mutex_unlock
(
&
g_kvGlobalMutex
);
return
EC_FAILURE
;
}
int
ret
=
strcpy_s
(
g_dataPath
,
MAX_KEY_PATH
+
1
,
path
);
pthread_mutex_unlock
(
&
g_kvGlobalMutex
);
return
EC_SUCCESS
;
return
(
ret
!=
EOK
)
?
EC_FAILURE
:
EC_SUCCESS
;
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录