From 0b7685929e1192ecb9a8286263f4d8da6f44f3ef Mon Sep 17 00:00:00 2001 From: SUE Date: Thu, 17 Mar 2022 07:08:58 +0000 Subject: [PATCH 1/3] Signed-off-by:hellohyh001 --- interfaces/plugin/src/sensor_js.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/interfaces/plugin/src/sensor_js.cpp b/interfaces/plugin/src/sensor_js.cpp index 43dd065c..d1eb5de2 100644 --- a/interfaces/plugin/src/sensor_js.cpp +++ b/interfaces/plugin/src/sensor_js.cpp @@ -260,7 +260,6 @@ static uint32_t RemoveCallback(napi_env env, int32_t sensorTypeId, napi_value ca std::vector::iterator iter; for (iter = callbackInfos.begin(); iter != callbackInfos.end();) { if (*iter == nullptr || (*iter)->callback[0] == nullptr) { - HiLog::Error(LABEL, "%{public}s arg is null", __func__); continue; } napi_value sensorCallback = nullptr; @@ -271,14 +270,13 @@ static uint32_t RemoveCallback(napi_env env, int32_t sensorTypeId, napi_value ca delete *iter; *iter = nullptr; callbackInfos.erase(iter++); - if (callbackInfos.empty()) { - g_onCallbackInfos.erase(sensorTypeId); - return 0; - } - } else { - ++iter; + break; } } + if (callbackInfos.empty()) { + g_onCallbackInfos.erase(sensorTypeId); + return 0; + } g_onCallbackInfos[sensorTypeId] = callbackInfos; return callbackInfos.size(); } -- Gitee From 720319bc54a0d5783502ab2157f464f6f4fd8c39 Mon Sep 17 00:00:00 2001 From: SUE Date: Fri, 18 Mar 2022 02:27:50 +0000 Subject: [PATCH 2/3] Signed-off-by:hellohyh001 --- interfaces/plugin/src/sensor_js.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/plugin/src/sensor_js.cpp b/interfaces/plugin/src/sensor_js.cpp index d1eb5de2..a7988334 100644 --- a/interfaces/plugin/src/sensor_js.cpp +++ b/interfaces/plugin/src/sensor_js.cpp @@ -258,7 +258,7 @@ static uint32_t RemoveCallback(napi_env env, int32_t sensorTypeId, napi_value ca { std::vector callbackInfos = g_onCallbackInfos[sensorTypeId]; std::vector::iterator iter; - for (iter = callbackInfos.begin(); iter != callbackInfos.end();) { + for (iter = callbackInfos.begin(); iter != callbackInfos.end(); iter++) { if (*iter == nullptr || (*iter)->callback[0] == nullptr) { continue; } -- Gitee From 01ee1b1ddcf3dabb62e268b08e8744f7c0c06928 Mon Sep 17 00:00:00 2001 From: SUE Date: Fri, 18 Mar 2022 03:45:40 +0000 Subject: [PATCH 3/3] Signed-off-by:hellohyh001 --- interfaces/plugin/src/sensor_js.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/plugin/src/sensor_js.cpp b/interfaces/plugin/src/sensor_js.cpp index a7988334..579362c8 100644 --- a/interfaces/plugin/src/sensor_js.cpp +++ b/interfaces/plugin/src/sensor_js.cpp @@ -258,7 +258,7 @@ static uint32_t RemoveCallback(napi_env env, int32_t sensorTypeId, napi_value ca { std::vector callbackInfos = g_onCallbackInfos[sensorTypeId]; std::vector::iterator iter; - for (iter = callbackInfos.begin(); iter != callbackInfos.end(); iter++) { + for (iter = callbackInfos.begin(); iter != callbackInfos.end(); ++iter) { if (*iter == nullptr || (*iter)->callback[0] == nullptr) { continue; } -- Gitee