diff --git a/interfaces/plugin/src/sensor_js.cpp b/interfaces/plugin/src/sensor_js.cpp index a706638b14e5b361c2901d2a208b45733a344303..7aea5a26adcc81e2c9a040c76a10f3cd6de3e887 100644 --- a/interfaces/plugin/src/sensor_js.cpp +++ b/interfaces/plugin/src/sensor_js.cpp @@ -70,6 +70,7 @@ 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); if (sensorTypeId == SENSOR_TYPE_ID_WEAR_DETECTION && callbackInfo->type == SUBSCRIBE_CALLBACK) { std::lock_guard onBodyLock(bodyMutex_); @@ -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 d999095436a91962c0b939359d51e2edf7ba7e20..563427c50c359bf0b08ee5df1d543a68ab09ef0e 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);