From 694424ca827e176047d8565a32ec8f634d023210 Mon Sep 17 00:00:00 2001 From: zianed Date: Tue, 5 Jul 2022 14:08:22 +0800 Subject: [PATCH 1/3] add NULL compare Signed-off-by: zianed --- adapter/common/kernel/liteos_m/softbus_adapter_timer.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/adapter/common/kernel/liteos_m/softbus_adapter_timer.c b/adapter/common/kernel/liteos_m/softbus_adapter_timer.c index 5da61a3cab..0dbb0c72e7 100644 --- a/adapter/common/kernel/liteos_m/softbus_adapter_timer.c +++ b/adapter/common/kernel/liteos_m/softbus_adapter_timer.c @@ -37,6 +37,10 @@ void *SoftBusCreateTimer(void **timerId, void *timerFunc, unsigned int type) int SoftBusStartTimer(void *timerId, unsigned int ms) { + if (timerId != NULL) { + HILOG_ERROR(SOFTBUS_HILOG_ID, "timerId is NULL"); + return SOFTBUS_ERR; + } if (osTimerStart(timerId, ms * osKernelGetTickFreq() / MS_PER_SECOND) != osOK) { HILOG_ERROR(SOFTBUS_HILOG_ID, "start timer failed"); (void)osTimerDelete(timerId); @@ -48,6 +52,10 @@ int SoftBusStartTimer(void *timerId, unsigned int ms) int SoftBusDeleteTimer(void *timerId) { + if (timerId != NULL) { + HILOG_ERROR(SOFTBUS_HILOG_ID, "timerId is NULL"); + return SOFTBUS_ERR; + } if (osTimerDelete(timerId) != osOK) { HILOG_ERROR(SOFTBUS_HILOG_ID, "delete timer failed"); return SOFTBUS_ERR; -- Gitee From db5dc4f70c4358cb8a788b544ce01ef4a7809533 Mon Sep 17 00:00:00 2001 From: zianed Date: Tue, 5 Jul 2022 14:41:13 +0800 Subject: [PATCH 2/3] add NULL compare Signed-off-by: zianed --- adapter/common/kernel/liteos_m/softbus_adapter_timer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/adapter/common/kernel/liteos_m/softbus_adapter_timer.c b/adapter/common/kernel/liteos_m/softbus_adapter_timer.c index 0dbb0c72e7..1f441bd179 100644 --- a/adapter/common/kernel/liteos_m/softbus_adapter_timer.c +++ b/adapter/common/kernel/liteos_m/softbus_adapter_timer.c @@ -39,7 +39,7 @@ int SoftBusStartTimer(void *timerId, unsigned int ms) { if (timerId != NULL) { HILOG_ERROR(SOFTBUS_HILOG_ID, "timerId is NULL"); - return SOFTBUS_ERR; + return SOFTBUS_ERR; } if (osTimerStart(timerId, ms * osKernelGetTickFreq() / MS_PER_SECOND) != osOK) { HILOG_ERROR(SOFTBUS_HILOG_ID, "start timer failed"); @@ -54,7 +54,7 @@ int SoftBusDeleteTimer(void *timerId) { if (timerId != NULL) { HILOG_ERROR(SOFTBUS_HILOG_ID, "timerId is NULL"); - return SOFTBUS_ERR; + return SOFTBUS_ERR; } if (osTimerDelete(timerId) != osOK) { HILOG_ERROR(SOFTBUS_HILOG_ID, "delete timer failed"); -- Gitee From 6cff734c7db36b6e1742a3523264c2ea129b79f4 Mon Sep 17 00:00:00 2001 From: zianed Date: Tue, 5 Jul 2022 14:44:39 +0800 Subject: [PATCH 3/3] add NULL compare Signed-off-by: zianed --- adapter/common/kernel/liteos_m/softbus_adapter_timer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/adapter/common/kernel/liteos_m/softbus_adapter_timer.c b/adapter/common/kernel/liteos_m/softbus_adapter_timer.c index 1f441bd179..62b4c207f1 100644 --- a/adapter/common/kernel/liteos_m/softbus_adapter_timer.c +++ b/adapter/common/kernel/liteos_m/softbus_adapter_timer.c @@ -37,7 +37,7 @@ void *SoftBusCreateTimer(void **timerId, void *timerFunc, unsigned int type) int SoftBusStartTimer(void *timerId, unsigned int ms) { - if (timerId != NULL) { + if (timerId == NULL) { HILOG_ERROR(SOFTBUS_HILOG_ID, "timerId is NULL"); return SOFTBUS_ERR; } @@ -52,7 +52,7 @@ int SoftBusStartTimer(void *timerId, unsigned int ms) int SoftBusDeleteTimer(void *timerId) { - if (timerId != NULL) { + if (timerId == NULL) { HILOG_ERROR(SOFTBUS_HILOG_ID, "timerId is NULL"); return SOFTBUS_ERR; } -- Gitee