diff --git a/frameworks/src/sensor_agent_proxy.c b/frameworks/src/sensor_agent_proxy.c index 62c347c34adafaf9bbd73a647f370998a23c644d..00f47568e4f0810d2bad10e979c7b57c4670a28e 100644 --- a/frameworks/src/sensor_agent_proxy.c +++ b/frameworks/src/sensor_agent_proxy.c @@ -137,7 +137,7 @@ int32_t GetSensorInfos(IOwner owner, IpcIo *reply) return SENSOR_ERROR_INVALID_PARAM; } ReadInt32(reply, &(notify->count)); - uint32_t len; + uint32_t len = 0; ReadUint32(reply, &len); uint8_t *data = (uint8_t *)ReadBuffer(reply, (size_t)len); if ((notify->count <= 0) || (data == NULL)) { @@ -169,7 +169,7 @@ int32_t GetSensorInfos(IOwner owner, IpcIo *reply) int32_t Notify(IOwner owner, int32_t code, IpcIo *reply) { HILOG_DEBUG(HILOG_MODULE_APP, "%s begin", __func__); - int32_t functionId; + int32_t functionId = -1; ReadInt32(reply, &functionId); if (functionId == SENSOR_SERVICE_ID_GetAllSensors) { return GetSensorInfos(owner, reply); @@ -212,10 +212,10 @@ int32_t SensorChannelCallback(uint32_t code, IpcIo *data, IpcIo *reply, MessageO HILOG_ERROR(HILOG_MODULE_APP, "%s failed, data is NULL", __func__); return SENSOR_ERROR_INVALID_PARAM; } - uint32_t len1; + uint32_t len1 = 0; ReadUint32(data, &len1); uint8_t *eventData = (uint8_t *)ReadBuffer(data, (size_t)len1); - uint32_t len2; + uint32_t len2 = 0; ReadUint32(data, &len2); uint8_t *sensorData = (uint8_t *)ReadBuffer(data, (size_t)len2); if ((eventData == NULL) || (sensorData == NULL)) { diff --git a/services/src/sensor_service.c b/services/src/sensor_service.c index 1bfd09dfdcf99c3fea321afd7b0bf2852e4ccf26..e04f215fe1c5b38b56fa57cc97658f2b6e69fd38 100644 --- a/services/src/sensor_service.c +++ b/services/src/sensor_service.c @@ -49,7 +49,7 @@ int32_t ActivateSensorInvoke(SensorFeatureApi *defaultApi, IpcIo *req, IpcIo *re { HILOG_DEBUG(HILOG_MODULE_APP, "[SERVICE:%s]: %s begin", SENSOR_SERVICE, __func__); WriteInt32(reply, SENSOR_SERVICE_ID_ActivateSensor); - int32_t sensorId; + int32_t sensorId = -1; ReadInt32(req, &sensorId); if (defaultApi == NULL) { HILOG_ERROR(HILOG_MODULE_APP, "[SERVICE:%s]: %s failed, defaultApi is null", SENSOR_SERVICE, __func__); @@ -67,7 +67,7 @@ int32_t DeactivateSensorInvoke(SensorFeatureApi *defaultApi, IpcIo *req, IpcIo * { HILOG_DEBUG(HILOG_MODULE_APP, "[SERVICE:%s]: %s begin", SENSOR_SERVICE, __func__); WriteInt32(reply, SENSOR_SERVICE_ID_DeactivateSensor); - int32_t sensorId; + int32_t sensorId = -1; ReadInt32(req, &sensorId); if (defaultApi == NULL) { HILOG_ERROR(HILOG_MODULE_APP, "[SERVICE:%s]: %s failed, defaultApi is null", SENSOR_SERVICE, __func__); @@ -85,7 +85,7 @@ int32_t SetBatchInvoke(SensorFeatureApi *defaultApi, IpcIo *req, IpcIo *reply) { HILOG_DEBUG(HILOG_MODULE_APP, "[SERVICE:%s]: %s begin", SENSOR_SERVICE, __func__); WriteInt32(reply, SENSOR_SERVICE_ID_SetBatchs); - int32_t sensorId; + int32_t sensorId = -1; ReadInt32(req, &sensorId); int64_t updateInterval; ReadInt64(req, &updateInterval); @@ -107,7 +107,7 @@ int32_t SubscribeSensorInvoke(SensorFeatureApi *defaultApi, IpcIo *req, IpcIo *r { HILOG_DEBUG(HILOG_MODULE_APP, "[SERVICE:%s]: %s begin", SENSOR_SERVICE, __func__); WriteInt32(reply, SENSOR_SERVICE_ID_SubscribeSensor); - int32_t sensorId; + int32_t sensorId = -1; ReadInt32(req, &sensorId); if (defaultApi == NULL) { HILOG_ERROR(HILOG_MODULE_APP, "[SERVICE:%s]: %s failed, defaultApi is null", SENSOR_SERVICE, __func__); @@ -126,7 +126,7 @@ int32_t UnsubscribeSensorInvoke(SensorFeatureApi *defaultApi, IpcIo *req, IpcIo { HILOG_DEBUG(HILOG_MODULE_APP, "[SERVICE:%s]: %s begin", SENSOR_SERVICE, __func__); WriteInt32(reply, SENSOR_SERVICE_ID_UnsubscribeSensor); - int32_t sensorId; + int32_t sensorId = -1; ReadInt32(req, &sensorId); if (defaultApi == NULL) { HILOG_ERROR(HILOG_MODULE_APP, "[SERVICE:%s]: %s failed, defaultApi is null", SENSOR_SERVICE, __func__); @@ -144,9 +144,9 @@ int32_t SetModeInvoke(SensorFeatureApi *defaultApi, IpcIo *req, IpcIo *reply) { HILOG_DEBUG(HILOG_MODULE_APP, "[SERVICE:%s]: %s begin", SENSOR_SERVICE, __func__); WriteInt32(reply, SENSOR_SERVICE_ID_SetMode); - int32_t sensorId; + int32_t sensorId = -1; ReadInt32(req, &sensorId); - int32_t mode; + int32_t mode = -1; ReadInt32(req, &mode); if (defaultApi == NULL) { HILOG_ERROR(HILOG_MODULE_APP, "[SERVICE:%s]: %s failed, defaultApi is null", SENSOR_SERVICE, __func__); @@ -164,9 +164,9 @@ int32_t SetOptionInvoke(SensorFeatureApi *defaultApi, IpcIo *req, IpcIo *reply) { HILOG_DEBUG(HILOG_MODULE_APP, "[SERVICE:%s]: %s begin", SENSOR_SERVICE, __func__); WriteInt32(reply, SENSOR_SERVICE_ID_SetOption); - int32_t sensorId; + int32_t sensorId = -1; ReadInt32(req, &sensorId); - int32_t option; + int32_t option = -1; ReadInt32(req, &option); if (defaultApi == NULL) { HILOG_ERROR(HILOG_MODULE_APP, "[SERVICE:%s]: %s failed, defaultApi is null", SENSOR_SERVICE, __func__);