diff --git a/interfaces/plugin/src/sensor_napi_utils.cpp b/interfaces/plugin/src/sensor_napi_utils.cpp index 752a498abfb755c26e31e6a510b0545e122ab15f..7625f82d788f4a679c0f91d612315df2e3af8f67 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) == 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.count(asyncCallbackInfo->type) == 0) { + if (g_convertfuncList.find(asyncCallbackInfo->type) == g_convertfuncList.end()) { HiLog::Error(LABEL, "%{public}s type invalid", __func__); return; } @@ -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; } @@ -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; } diff --git a/services/sensor/src/sensor_service.cpp b/services/sensor/src/sensor_service.cpp index bf0cc9b5fbf47cec71e0964f77a40934ce471314..564e55959368d58a1d1c7827bd1fdeaef22d4b77 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; } } }