From 8219e6873f6f1b546be410dad1c05e2fa68c30de Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Tue, 29 Mar 2022 14:58:41 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E5=8E=BB=E6=8E=89return=20false?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-yaoyao777 --- services/sensor/src/sensor_service.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/services/sensor/src/sensor_service.cpp b/services/sensor/src/sensor_service.cpp index bf0cc9b5..564e5595 100644 --- a/services/sensor/src/sensor_service.cpp +++ b/services/sensor/src/sensor_service.cpp @@ -133,7 +133,6 @@ bool SensorService::InitSensorList() for (const auto &it : sensors_) { if (!(sensorMap_.insert(std::make_pair(it.GetSensorId(), it)).second)) { HiLog::Warn(LABEL, "%{public}s sensorMap_ Insert failed", __func__); - return false; } } } -- Gitee From a0137dd361e2cec557b04db26f78a61a48cf642f Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Tue, 29 Mar 2022 15:25:11 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E5=B0=86count=E6=94=B9=E4=B8=BAfind?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-yaoyao777 --- interfaces/plugin/src/sensor_napi_utils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/plugin/src/sensor_napi_utils.cpp b/interfaces/plugin/src/sensor_napi_utils.cpp index 752a498a..0f402e42 100644 --- a/interfaces/plugin/src/sensor_napi_utils.cpp +++ b/interfaces/plugin/src/sensor_napi_utils.cpp @@ -279,7 +279,7 @@ void ConvertToSensorData(napi_env env, AsyncCallbackInfo *asyncCallbackInfo, nap { napi_get_undefined(env, &result[0]); int32_t sensorTypeId = asyncCallbackInfo->data.sensorData.sensorTypeId; - if ((g_sensorAttributeList.count(sensorTypeId)) == 0 + if ((g_sensorAttributeList.find(sensorTypeId)) == 0 || g_sensorAttributeList[sensorTypeId].size() > (asyncCallbackInfo->data.sensorData.dataLength / sizeof(float))) { HiLog::Error(LABEL, "%{public}s count of sensorTypeId is zero", __func__); -- Gitee From e209db33730caae8bd217ce3e289db9f69c0a36e Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Tue, 29 Mar 2022 17:39:53 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E5=B0=86count=E6=94=B9=E4=B8=BAfind?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-yaoyao777 --- interfaces/plugin/src/sensor_napi_utils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/plugin/src/sensor_napi_utils.cpp b/interfaces/plugin/src/sensor_napi_utils.cpp index 0f402e42..6e4581c5 100644 --- a/interfaces/plugin/src/sensor_napi_utils.cpp +++ b/interfaces/plugin/src/sensor_napi_utils.cpp @@ -279,7 +279,7 @@ void ConvertToSensorData(napi_env env, AsyncCallbackInfo *asyncCallbackInfo, nap { napi_get_undefined(env, &result[0]); int32_t sensorTypeId = asyncCallbackInfo->data.sensorData.sensorTypeId; - if ((g_sensorAttributeList.find(sensorTypeId)) == 0 + if ((g_sensorAttributeList.find(sensorTypeId) == g_sensorAttributeList.end()) || g_sensorAttributeList[sensorTypeId].size() > (asyncCallbackInfo->data.sensorData.dataLength / sizeof(float))) { HiLog::Error(LABEL, "%{public}s count of sensorTypeId is zero", __func__); -- Gitee From e2ad2d5b1c620367284a005307145739dca13598 Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Wed, 30 Mar 2022 09:42:53 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E5=B0=86count=E6=94=B9=E4=B8=BAfind?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-yaoyao777 --- interfaces/plugin/src/sensor_napi_utils.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interfaces/plugin/src/sensor_napi_utils.cpp b/interfaces/plugin/src/sensor_napi_utils.cpp index 6e4581c5..cfe67e6c 100644 --- a/interfaces/plugin/src/sensor_napi_utils.cpp +++ b/interfaces/plugin/src/sensor_napi_utils.cpp @@ -394,7 +394,7 @@ void EmitAsyncCallbackWork(AsyncCallbackInfo *asyncCallbackInfo) napi_get_reference_value(env, asyncCallbackInfo->callback[0], &callback); napi_value callResult = nullptr; napi_value result[2] = {0}; - if (g_convertfuncList.count(asyncCallbackInfo->type) == 0) { + if ((g_sensorAttributeList.find(asyncCallbackInfo->type) == g_sensorAttributeList.end()) { HiLog::Error(LABEL, "%{public}s type invalid", __func__); return; } @@ -478,7 +478,7 @@ void EmitPromiseWork(AsyncCallbackInfo *asyncCallbackInfo) return; } napi_value result[2] = {0}; - if (g_convertfuncList.count(asyncCallbackInfo->type) == 0) { + if ((g_convertfuncList.find(asyncCallbackInfo->type) == g_convertfuncList.end()) { HiLog::Error(LABEL, "%{public}s type invalid", __func__); return; } -- Gitee From 250efb670e6bee2e391b6af5e0220c1c8bf9bc9c Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Wed, 30 Mar 2022 09:44:23 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E5=B0=86count=E6=94=B9=E4=B8=BAfind?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-yaoyao777 --- interfaces/plugin/src/sensor_napi_utils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/plugin/src/sensor_napi_utils.cpp b/interfaces/plugin/src/sensor_napi_utils.cpp index cfe67e6c..cb676b0c 100644 --- a/interfaces/plugin/src/sensor_napi_utils.cpp +++ b/interfaces/plugin/src/sensor_napi_utils.cpp @@ -394,7 +394,7 @@ void EmitAsyncCallbackWork(AsyncCallbackInfo *asyncCallbackInfo) napi_get_reference_value(env, asyncCallbackInfo->callback[0], &callback); napi_value callResult = nullptr; napi_value result[2] = {0}; - if ((g_sensorAttributeList.find(asyncCallbackInfo->type) == g_sensorAttributeList.end()) { + if ((g_convertfuncList.find(asyncCallbackInfo->type) == g_convertfuncList.end()) { HiLog::Error(LABEL, "%{public}s type invalid", __func__); return; } -- Gitee From 68303e998eba1dc16551584f0cd10075d0035c32 Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Wed, 30 Mar 2022 09:45:24 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E5=B0=86count=E6=94=B9=E4=B8=BAfind?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-yaoyao777 --- interfaces/plugin/src/sensor_napi_utils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/plugin/src/sensor_napi_utils.cpp b/interfaces/plugin/src/sensor_napi_utils.cpp index cb676b0c..2c301474 100644 --- a/interfaces/plugin/src/sensor_napi_utils.cpp +++ b/interfaces/plugin/src/sensor_napi_utils.cpp @@ -279,7 +279,7 @@ void ConvertToSensorData(napi_env env, AsyncCallbackInfo *asyncCallbackInfo, nap { napi_get_undefined(env, &result[0]); int32_t sensorTypeId = asyncCallbackInfo->data.sensorData.sensorTypeId; - if ((g_sensorAttributeList.find(sensorTypeId) == g_sensorAttributeList.end()) + if ((g_sensorAttributeList.find(sensorTypeId) == g_sensorAttributeList.end()) { || g_sensorAttributeList[sensorTypeId].size() > (asyncCallbackInfo->data.sensorData.dataLength / sizeof(float))) { HiLog::Error(LABEL, "%{public}s count of sensorTypeId is zero", __func__); -- Gitee From b58024069adbe6e73e09edd29ee1d7fe4a5a73ae Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Wed, 30 Mar 2022 10:26:23 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=E5=B0=86count=E6=94=B9=E4=B8=BAfind?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-yaoyao777 --- interfaces/plugin/src/sensor_napi_utils.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/interfaces/plugin/src/sensor_napi_utils.cpp b/interfaces/plugin/src/sensor_napi_utils.cpp index 2c301474..42a423ed 100644 --- a/interfaces/plugin/src/sensor_napi_utils.cpp +++ b/interfaces/plugin/src/sensor_napi_utils.cpp @@ -279,7 +279,7 @@ void ConvertToSensorData(napi_env env, AsyncCallbackInfo *asyncCallbackInfo, nap { napi_get_undefined(env, &result[0]); int32_t sensorTypeId = asyncCallbackInfo->data.sensorData.sensorTypeId; - if ((g_sensorAttributeList.find(sensorTypeId) == g_sensorAttributeList.end()) { + if (g_sensorAttributeList.find(sensorTypeId) == g_sensorAttributeList.end() || g_sensorAttributeList[sensorTypeId].size() > (asyncCallbackInfo->data.sensorData.dataLength / sizeof(float))) { HiLog::Error(LABEL, "%{public}s count of sensorTypeId is zero", __func__); @@ -394,7 +394,7 @@ void EmitAsyncCallbackWork(AsyncCallbackInfo *asyncCallbackInfo) napi_get_reference_value(env, asyncCallbackInfo->callback[0], &callback); napi_value callResult = nullptr; napi_value result[2] = {0}; - if ((g_convertfuncList.find(asyncCallbackInfo->type) == g_convertfuncList.end()) { + if (g_convertfuncList.find(asyncCallbackInfo->type) == g_convertfuncList.end()) { HiLog::Error(LABEL, "%{public}s type invalid", __func__); return; } @@ -478,7 +478,7 @@ void EmitPromiseWork(AsyncCallbackInfo *asyncCallbackInfo) return; } napi_value result[2] = {0}; - if ((g_convertfuncList.find(asyncCallbackInfo->type) == g_convertfuncList.end()) { + if (g_convertfuncList.find(asyncCallbackInfo->type) == g_convertfuncList.end()) { HiLog::Error(LABEL, "%{public}s type invalid", __func__); return; } -- Gitee From 10f8e3fc45065983b2f7217a59a3586e0633d1b3 Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Wed, 30 Mar 2022 10:30:07 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=E5=B0=86count=E6=94=B9=E4=B8=BAfind?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-yaoyao777 --- interfaces/plugin/src/sensor_napi_utils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/plugin/src/sensor_napi_utils.cpp b/interfaces/plugin/src/sensor_napi_utils.cpp index 42a423ed..7625f82d 100644 --- a/interfaces/plugin/src/sensor_napi_utils.cpp +++ b/interfaces/plugin/src/sensor_napi_utils.cpp @@ -445,7 +445,7 @@ void EmitUvEventLoop(AsyncCallbackInfo **asyncCallbackInfo) napi_get_reference_value(env, asyncCallbackInfo->callback[0], &callback); napi_value callResult = nullptr; napi_value result[2] = {0}; - if (g_convertfuncList.count(asyncCallbackInfo->type) == 0) { + if (g_convertfuncList.find(asyncCallbackInfo->type) == g_convertfuncList.end()) { HiLog::Error(LABEL, "%{public}s type invalid", __func__); return; } -- Gitee