From 941c4b3181000182e7348b93f115a0b4158cc8c1 Mon Sep 17 00:00:00 2001 From: yue Date: Wed, 1 Jun 2022 10:34:47 +0800 Subject: [PATCH] fix:add condition to check null pointer Signed-off-by: yue --- .../hdi_sample/sample_client_cpp/sample_client_cpp_test.cpp | 2 +- .../test/hdi_sample/sample_service_cpp/sample_service_stub.cpp | 3 ++- uhdf2/host/src/hdf_device_thread.c | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/uhdf2/hdi/test/hdi_sample/sample_client_cpp/sample_client_cpp_test.cpp b/uhdf2/hdi/test/hdi_sample/sample_client_cpp/sample_client_cpp_test.cpp index 06d01fa..7918135 100644 --- a/uhdf2/hdi/test/hdi_sample/sample_client_cpp/sample_client_cpp_test.cpp +++ b/uhdf2/hdi/test/hdi_sample/sample_client_cpp/sample_client_cpp_test.cpp @@ -74,7 +74,7 @@ HWTEST_F(SampleHdiCppTest, HdiCppTest001, TestSize.Level1) // passthrough mode get interface object HWTEST_F(SampleHdiCppTest, HdiCppTest002, TestSize.Level1) { - OHOS::sptr sampleService = ISample::Get(TEST_SERVICE_NAME, true); + OHOS::sptr sampleService = ISample::Get(true); ASSERT_TRUE(sampleService != nullptr); OHOS::sptr fooInterface = nullptr; int ret = sampleService->GetInterface(fooInterface); diff --git a/uhdf2/hdi/test/hdi_sample/sample_service_cpp/sample_service_stub.cpp b/uhdf2/hdi/test/hdi_sample/sample_service_cpp/sample_service_stub.cpp index 25caedd..3905fc9 100644 --- a/uhdf2/hdi/test/hdi_sample/sample_service_cpp/sample_service_stub.cpp +++ b/uhdf2/hdi/test/hdi_sample/sample_service_cpp/sample_service_stub.cpp @@ -48,7 +48,8 @@ sptr ISample::Get(const std::string &serviceName, bool isStub) sptr ISample::Get(bool isStub) { - return ISample::Get("sample_service", isStub); + std::string defaultName = "sample_service"; + return ISample::Get(defaultName, isStub); } SampleServiceStub::SampleServiceStub(const sptr &serviceImpl) : diff --git a/uhdf2/host/src/hdf_device_thread.c b/uhdf2/host/src/hdf_device_thread.c index 9bb01a6..44514ae 100644 --- a/uhdf2/host/src/hdf_device_thread.c +++ b/uhdf2/host/src/hdf_device_thread.c @@ -49,7 +49,7 @@ int32_t DeviceThreadMessageHandler(struct HdfMessageTask *task, struct HdfMessag int DeviceThreadAttach(struct DeviceThread *inst, struct IHdfDevice *device, struct HdfDeviceNode *service) { - if (inst != NULL || device == NULL || service == NULL) { + if (inst == NULL || device == NULL || service == NULL) { return HDF_ERR_INVALID_PARAM; } -- Gitee