From 85191660667a7cdd7cec98f30299ad051ab8a150 Mon Sep 17 00:00:00 2001 From: Gymee <8039110+Gymee@user.noreply.gitee.com> Date: Sat, 19 Sep 2020 18:11:43 +0800 Subject: [PATCH] =?UTF-8?q?!14=20=E3=80=90=E8=BD=BB=E9=87=8F=E7=BA=A7=20PR?= =?UTF-8?q?=E3=80=91=EF=BC=9Atweak=20code=20for=20simplicity=20Merge=20pul?= =?UTF-8?q?l=20request=20!14=20from=20Gymee/N/A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kv_store/src/kvstore_common/kvstore_common.c | 6 ++---- kv_store/src/kvstore_impl_hal/kv_store.c | 4 ++-- kv_store/src/kvstore_impl_posix/kv_store.c | 3 +-- timer_task/src/nativeapi_timer_task.c | 16 ++++++---------- 4 files changed, 11 insertions(+), 18 deletions(-) diff --git a/kv_store/src/kvstore_common/kvstore_common.c b/kv_store/src/kvstore_common/kvstore_common.c index 2b713df..202591f 100755 --- a/kv_store/src/kvstore_common/kvstore_common.c +++ b/kv_store/src/kvstore_common/kvstore_common.c @@ -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 diff --git a/kv_store/src/kvstore_impl_hal/kv_store.c b/kv_store/src/kvstore_impl_hal/kv_store.c index c1bec9a..3d4985b 100755 --- a/kv_store/src/kvstore_impl_hal/kv_store.c +++ b/kv_store/src/kvstore_impl_hal/kv_store.c @@ -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) diff --git a/kv_store/src/kvstore_impl_posix/kv_store.c b/kv_store/src/kvstore_impl_posix/kv_store.c index dfe9015..24bc57c 100755 --- a/kv_store/src/kvstore_impl_posix/kv_store.c +++ b/kv_store/src/kvstore_impl_posix/kv_store.c @@ -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; } diff --git a/timer_task/src/nativeapi_timer_task.c b/timer_task/src/nativeapi_timer_task.c index a47f3c8..1622d73 100755 --- a/timer_task/src/nativeapi_timer_task.c +++ b/timer_task/src/nativeapi_timer_task.c @@ -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 -- GitLab