From a1148d52ea5db6a8b2e9468ce23f4a16552972d7 Mon Sep 17 00:00:00 2001 From: wuzhihuitmac Date: Fri, 18 Aug 2023 11:18:45 +0000 Subject: [PATCH] Code specification modification Signed-off-by: wuzhihuitmac Change-Id: Ia0ddc6a58d6933f7eac05d7e322b7edd00befd36 --- interfaces/plugin/src/sensor_js.cpp | 10 ++++++---- services/sensor/src/sensor_dump.cpp | 6 +++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/interfaces/plugin/src/sensor_js.cpp b/interfaces/plugin/src/sensor_js.cpp index 7d0a477b..7d7f32e2 100644 --- a/interfaces/plugin/src/sensor_js.cpp +++ b/interfaces/plugin/src/sensor_js.cpp @@ -376,7 +376,7 @@ static int32_t RemoveCallback(napi_env env, int32_t sensorTypeId, napi_value cal CALL_LOG_ENTER; std::lock_guard onCallbackLock(onMutex_); std::vector> callbackInfos = g_onCallbackInfos[sensorTypeId]; - for (auto iter = callbackInfos.begin(); iter != callbackInfos.end(); ++iter) { + for (auto iter = callbackInfos.begin(); iter != callbackInfos.end();) { CHKPC(*iter); if ((*iter)->env != env) { continue; @@ -387,9 +387,11 @@ static int32_t RemoveCallback(napi_env env, int32_t sensorTypeId, napi_value cal continue; } if (IsSameValue(env, callback, sensorCallback)) { - callbackInfos.erase(iter++); + iter = callbackInfos.erase(iter); SEN_HILOGD("Remove callback success"); break; + } else { + ++iter; } } if (callbackInfos.empty()) { @@ -735,7 +737,7 @@ static napi_value CreateQuaternion(napi_env env, napi_callback_info info) napi_value thisVar = nullptr; napi_status status = napi_get_cb_info(env, info, &argc, args, &thisVar, nullptr); if (status != napi_ok || argc < 1) { - ThrowErr(env, PARAMETER_ERROR, "napi_get_cb_info fail or number of parameter invalid"); + ThrowErr(env, PARAMETER_ERROR, "napi_get_cb_info failed or number of parameter invalid"); return nullptr; } if (!IsMatchArrayType(env, args[0])) { @@ -747,7 +749,7 @@ static napi_value CreateQuaternion(napi_env env, napi_callback_info info) CHKPP(asyncCallbackInfo); std::vector rotationVector; if (!GetFloatArray(env, args[0], rotationVector)) { - ThrowErr(env, PARAMETER_ERROR, "Get rotationVector fail"); + ThrowErr(env, PARAMETER_ERROR, "Get rotationVector failed"); return nullptr; } std::vector quaternion(QUATERNION_LENGTH); diff --git a/services/sensor/src/sensor_dump.cpp b/services/sensor/src/sensor_dump.cpp index cd5c0fb9..5b231d2f 100644 --- a/services/sensor/src/sensor_dump.cpp +++ b/services/sensor/src/sensor_dump.cpp @@ -90,8 +90,8 @@ void SensorDump::ParseCommand(int32_t fd, const std::vector &args, } } if (count > MAX_DUMP_PARAMETERS) { - SEN_HILOGE("cmd param number not more than 32"); - dprintf(fd, "cmd param number not more than 32\n"); + SEN_HILOGE("Cmd param number not more than 32"); + dprintf(fd, "Cmd param number not more than 32\n"); return; } int32_t optionIndex = 0; @@ -106,7 +106,7 @@ void SensorDump::ParseCommand(int32_t fd, const std::vector &args, char **argv = new (std::nothrow) char *[args.size()]; CHKPV(argv); if (memset_s(argv, args.size() * sizeof(char *), 0, args.size() * sizeof(char *)) != EOK) { - SEN_HILOGE("Call memset_s failed"); + SEN_HILOGE("memset_s failed"); delete[] argv; return; } -- Gitee