From 647a903782041ff26bd54059584ea48e868b8bce Mon Sep 17 00:00:00 2001 From: h00514358 Date: Fri, 2 Jul 2021 03:05:31 +0000 Subject: [PATCH] modify codex issue huiyuehong@huawei.com Signed-off-by: h00514358 --- services/src/sensor_service.c | 40 +++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/services/src/sensor_service.c b/services/src/sensor_service.c index 67b679b..5064f6b 100755 --- a/services/src/sensor_service.c +++ b/services/src/sensor_service.c @@ -26,6 +26,11 @@ int32_t GetAllSensorsInvoke(SensorFeatureApi *defaultApi, IpcIo *req, IpcIo *rep HILOG_DEBUG(HILOG_MODULE_APP, "[SERVICE:%s]: %s begin", SENSOR_SERVICE, __func__); SensorInfo *sensorInfo = NULL; int32_t count = 0; + if (defaultApi == NULL) { + HILOG_ERROR(HILOG_MODULE_APP, "[SERVICE:%s]: %s failed, defaultApi is null", SENSOR_SERVICE, __func__); + IpcIoPushInt32(reply, SENSOR_ERROR_UNKNOWN); + return SENSOR_ERROR_UNKNOWN; + } int32_t ret = defaultApi->GetAllSensors(&sensorInfo, &count); IpcIoPushInt32(reply, SENSOR_SERVICE_ID_GetAllSensors); if (ret != SENSOR_OK) { @@ -47,6 +52,11 @@ int32_t ActivateSensorInvoke(SensorFeatureApi *defaultApi, IpcIo *req, IpcIo *re { HILOG_DEBUG(HILOG_MODULE_APP, "[SERVICE:%s]: %s begin", SENSOR_SERVICE, __func__); int32_t sensorId = IpcIoPopInt32(req); + if (defaultApi == NULL) { + HILOG_ERROR(HILOG_MODULE_APP, "[SERVICE:%s]: %s failed, defaultApi is null", SENSOR_SERVICE, __func__); + IpcIoPushInt32(reply, SENSOR_ERROR_UNKNOWN); + return SENSOR_ERROR_UNKNOWN; + } SensorUser sensorUser; int32_t ret = defaultApi->ActivateSensor(sensorId, &sensorUser); IpcIoPushInt32(reply, SENSOR_SERVICE_ID_ActivateSensor); @@ -58,6 +68,11 @@ int32_t DeactivateSensorInvoke(SensorFeatureApi *defaultApi, IpcIo *req, IpcIo * { HILOG_DEBUG(HILOG_MODULE_APP, "[SERVICE:%s]: %s begin", SENSOR_SERVICE, __func__); int32_t sensorId = IpcIoPopInt32(req); + if (defaultApi == NULL) { + HILOG_ERROR(HILOG_MODULE_APP, "[SERVICE:%s]: %s failed, defaultApi is null", SENSOR_SERVICE, __func__); + IpcIoPushInt32(reply, SENSOR_ERROR_UNKNOWN); + return SENSOR_ERROR_UNKNOWN; + } SensorUser sensorUser; int32_t ret = defaultApi->DeactivateSensor(sensorId, &sensorUser); IpcIoPushInt32(reply, SENSOR_SERVICE_ID_DeactivateSensor); @@ -71,6 +86,11 @@ int32_t SetBatchInvoke(SensorFeatureApi *defaultApi, IpcIo *req, IpcIo *reply) int32_t sensorId = IpcIoPopInt32(req); int64_t updateInterval = IpcIoPopInt64(req); int64_t maxDelay = IpcIoPopInt64(req); + if (defaultApi == NULL) { + HILOG_ERROR(HILOG_MODULE_APP, "[SERVICE:%s]: %s failed, defaultApi is null", SENSOR_SERVICE, __func__); + IpcIoPushInt32(reply, SENSOR_ERROR_UNKNOWN); + return SENSOR_ERROR_UNKNOWN; + } SensorUser sensorUser; int32_t ret = defaultApi->SetBatch(sensorId, &sensorUser, updateInterval, maxDelay); IpcIoPushInt32(reply, SENSOR_SERVICE_ID_SetBatchs); @@ -82,6 +102,11 @@ int32_t SubscribeSensorInvoke(SensorFeatureApi *defaultApi, IpcIo *req, IpcIo *r { HILOG_DEBUG(HILOG_MODULE_APP, "[SERVICE:%s]: %s begin", SENSOR_SERVICE, __func__); int32_t sensorId = IpcIoPopInt32(req); + if (defaultApi == NULL) { + HILOG_ERROR(HILOG_MODULE_APP, "[SERVICE:%s]: %s failed, defaultApi is null", SENSOR_SERVICE, __func__); + IpcIoPushInt32(reply, SENSOR_ERROR_UNKNOWN); + return SENSOR_ERROR_UNKNOWN; + } SensorUser sensorUser; int32_t ret = defaultApi->SubscribeSensor(sensorId, &sensorUser); SetSvcIdentity(req, reply); @@ -94,6 +119,11 @@ int32_t UnsubscribeSensorInvoke(SensorFeatureApi *defaultApi, IpcIo *req, IpcIo { HILOG_DEBUG(HILOG_MODULE_APP, "[SERVICE:%s]: %s begin", SENSOR_SERVICE, __func__); int32_t sensorId = IpcIoPopInt32(req); + if (defaultApi == NULL) { + HILOG_ERROR(HILOG_MODULE_APP, "[SERVICE:%s]: %s failed, defaultApi is null", SENSOR_SERVICE, __func__); + IpcIoPushInt32(reply, SENSOR_ERROR_UNKNOWN); + return SENSOR_ERROR_UNKNOWN; + } SensorUser sensorUser; int32_t ret = defaultApi->UnsubscribeSensor(sensorId, &sensorUser); IpcIoPushInt32(reply, SENSOR_SERVICE_ID_UnsubscribeSensor); @@ -106,6 +136,11 @@ int32_t SetModeInvoke(SensorFeatureApi *defaultApi, IpcIo *req, IpcIo *reply) HILOG_DEBUG(HILOG_MODULE_APP, "[SERVICE:%s]: %s begin", SENSOR_SERVICE, __func__); int32_t sensorId = IpcIoPopInt32(req); int32_t mode = IpcIoPopInt32(req); + if (defaultApi == NULL) { + HILOG_ERROR(HILOG_MODULE_APP, "[SERVICE:%s]: %s failed, defaultApi is null", SENSOR_SERVICE, __func__); + IpcIoPushInt32(reply, SENSOR_ERROR_UNKNOWN); + return SENSOR_ERROR_UNKNOWN; + } SensorUser sensorUser; int32_t ret = defaultApi->SetMode(sensorId, &sensorUser, mode); IpcIoPushInt32(reply, SENSOR_SERVICE_ID_SetMode); @@ -118,6 +153,11 @@ int32_t SetOptionInvoke(SensorFeatureApi *defaultApi, IpcIo *req, IpcIo *reply) HILOG_DEBUG(HILOG_MODULE_APP, "[SERVICE:%s]: %s begin", SENSOR_SERVICE, __func__); int32_t sensorId = IpcIoPopInt32(req); int32_t option = IpcIoPopInt32(req); + if (defaultApi == NULL) { + HILOG_ERROR(HILOG_MODULE_APP, "[SERVICE:%s]: %s failed, defaultApi is null", SENSOR_SERVICE, __func__); + IpcIoPushInt32(reply, SENSOR_ERROR_UNKNOWN); + return SENSOR_ERROR_UNKNOWN; + } SensorUser sensorUser; int32_t ret = defaultApi->SetOption(sensorId, &sensorUser, option); IpcIoPushInt32(reply, SENSOR_SERVICE_ID_SetOption); -- Gitee