提交 85191660 编写于 作者: G Gymee 提交者: openharmony_ci

!14 【轻量级 PR】:tweak code for simplicity

Merge pull request !14 from Gymee/N/A
上级 f8cbe259
......@@ -186,9 +186,7 @@ int ClearKVCacheInner(void)
}
g_itemHeader = NULL;
g_itemTail = NULL;
if (g_sum != 0) {
return EC_FAILURE;
}
return EC_SUCCESS;
return (g_sum != 0) ? EC_FAILURE : EC_SUCCESS;
}
#endif
\ No newline at end of file
......@@ -140,8 +140,8 @@ int UtilsSetValue(const char* key, const char* value)
currentNum++;
}
}
ret = SetCurrentItem(currentNum);
return ret;
return SetCurrentItem(currentNum);
}
int UtilsDeleteValue(const char* key)
......
......@@ -301,9 +301,8 @@ int UtilsDeleteValue(const char* key)
#ifdef FEATURE_KV_CACHE
int ClearKVCache(void)
{
int ret;
pthread_mutex_lock(&g_kvGlobalMutex);
ret = ClearKVCacheInner();
int ret = ClearKVCacheInner();
pthread_mutex_unlock(&g_kvGlobalMutex);
return ret;
}
......
......@@ -29,22 +29,19 @@ int StartTimerTask(bool isPeriodic, const unsigned int delay, void* userCallback
if (userCallback == NULL) {
return EC_FAILURE;
}
KalTimerType timerType;
if (isPeriodic) {
timerType = KAL_TIMER_PERIODIC;
} else {
timerType = KAL_TIMER_ONCE;
}
KalTimerType timerType = isPeriodic ? KAL_TIMER_PERIODIC : KAL_TIMER_ONCE;
KalTimerId timerId = KalTimerCreate((KalTimerProc)userCallback, timerType, userContext, delay);
if (timerId == NULL) {
return EC_FAILURE;
}
int ret = KalTimerStart(timerId);
if (ret != KAL_OK) {
if (KalTimerStart(timerId) != KAL_OK) {
StopTimerTask(timerId);
return EC_FAILURE;
}
*timerHandle = timerId;
return EC_SUCCESS;
}
......@@ -53,6 +50,5 @@ int StopTimerTask(const timerHandle_t timerHandle)
if (timerHandle == NULL) {
return EC_FAILURE;
}
int ret = KalTimerDelete((KalTimerId)timerHandle);
return ret;
return KalTimerDelete((KalTimerId)timerHandle);;
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册