From 6b27f14a826e807c25eba9c9d066fc6d3122a22d Mon Sep 17 00:00:00 2001 From: HYH Date: Mon, 26 Sep 2022 06:51:29 +0000 Subject: [PATCH 1/2] Modify sensor warning Signed-off-by: HYH --- interfaces/plugin/src/sensor_js.cpp | 2 +- services/sensor/src/sensor_service.cpp | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/interfaces/plugin/src/sensor_js.cpp b/interfaces/plugin/src/sensor_js.cpp index 7bd587d4..b3cc2483 100644 --- a/interfaces/plugin/src/sensor_js.cpp +++ b/interfaces/plugin/src/sensor_js.cpp @@ -71,6 +71,7 @@ static bool copySensorData(sptr callbackInfo, SensorEvent *ev callbackInfo->data.sensorData.dataLength = event->dataLen; callbackInfo->data.sensorData.timestamp = event->timestamp; auto data = reinterpret_cast(event->data); + CHKPF(data); if (sensorTypeId == SENSOR_TYPE_ID_WEAR_DETECTION && callbackInfo->type == SUBSCRIBE_CALLBACK) { std::lock_guard onBodyLock(bodyMutex_); g_bodyState = *data; @@ -78,7 +79,6 @@ static bool copySensorData(sptr callbackInfo, SensorEvent *ev (fabs(g_bodyState - BODY_STATE_EXCEPT) < THREESHOLD) ? true : false; return true; } - CHKPF(data); if (memcpy_s(callbackInfo->data.sensorData.data, event->dataLen, data, event->dataLen) != EOK) { SEN_HILOGE("Copy data failed"); return false; diff --git a/services/sensor/src/sensor_service.cpp b/services/sensor/src/sensor_service.cpp index 7018e889..8d8f6ac5 100644 --- a/services/sensor/src/sensor_service.cpp +++ b/services/sensor/src/sensor_service.cpp @@ -157,7 +157,6 @@ void SensorService::ReportSensorSysEvent(uint32_t sensorId, bool enable, int32_t sensorManager_.GetPackageName(tokenId, packageName); const int logLevel = 4; int32_t uid = clientInfo_.GetUidByPid(pid); - std::string message; if (enable) { HiSysEvent::Write(HiSysEvent::Domain::SENSOR, "ENABLE_SENSOR", HiSysEvent::EventType::STATISTIC, "LEVEL", logLevel, "UID", uid, "PKG_NAME", packageName, "TYPE", sensorId); -- Gitee From 00c6d2e2d07edaa10e64a8eb8fe4dcb7f6b42be8 Mon Sep 17 00:00:00 2001 From: HYH Date: Mon, 26 Sep 2022 07:46:31 +0000 Subject: [PATCH 2/2] Modify sensor waring Signed-off-by: HYH --- 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 b3cc2483..04feed7c 100644 --- a/interfaces/plugin/src/sensor_js.cpp +++ b/interfaces/plugin/src/sensor_js.cpp @@ -70,8 +70,8 @@ static bool copySensorData(sptr callbackInfo, SensorEvent *ev callbackInfo->data.sensorData.sensorTypeId = sensorTypeId; callbackInfo->data.sensorData.dataLength = event->dataLen; callbackInfo->data.sensorData.timestamp = event->timestamp; + CHKPF(event->data); auto data = reinterpret_cast(event->data); - CHKPF(data); if (sensorTypeId == SENSOR_TYPE_ID_WEAR_DETECTION && callbackInfo->type == SUBSCRIBE_CALLBACK) { std::lock_guard onBodyLock(bodyMutex_); g_bodyState = *data; -- Gitee