From 59fbb2cf0e43247924fdaa248e77300841e4e109 Mon Sep 17 00:00:00 2001 From: tangfan <1824525929@qq.com> Date: Wed, 23 Mar 2022 10:48:53 +0800 Subject: [PATCH 1/2] fix code style Signed-off-by: tangfan <1824525929@qq.com> --- common/utils/include/distributed_hardware_errno.h | 1 + .../src/distributed_hardware_proxy.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/common/utils/include/distributed_hardware_errno.h b/common/utils/include/distributed_hardware_errno.h index 2bab9497..ffc05fd2 100644 --- a/common/utils/include/distributed_hardware_errno.h +++ b/common/utils/include/distributed_hardware_errno.h @@ -82,6 +82,7 @@ namespace DistributedHardware { constexpr int32_t ERR_DH_FWK_SERVICE_STRING_IS_EMPTY = -10803; constexpr int32_t ERR_DH_FWK_SERVICE_LOCAL_VERSION_NOT_EXIST = -10804; constexpr int32_t ERR_DH_FWK_SERVICE_WRITE_TOKEN_FAIL = -10805; + constexpr int32_t ERR_DH_FWK_SERVICE_REMOTE_IS_NULL = -10806; /* AccessManager errno, range: [-10900, -10999] */ constexpr int32_t ERR_DH_FWK_ACCESS_INIT_DM_FAILED = -10900; diff --git a/services/distributedhardwarefwkserviceimpl/src/distributed_hardware_proxy.cpp b/services/distributedhardwarefwkserviceimpl/src/distributed_hardware_proxy.cpp index 72867751..0ecce1d2 100644 --- a/services/distributedhardwarefwkserviceimpl/src/distributed_hardware_proxy.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/distributed_hardware_proxy.cpp @@ -43,7 +43,12 @@ int32_t DistributedHardwareProxy::QuerySinkVersion(std::unordered_mapSendRequest(QUERY_SINK_VERSION, data, reply, option); + sptr remote = Remote(); + if (remote == nullptr) { + DHLOGE("remote service is null"); + return ERR_DH_FWK_SERVICE_REMOTE_IS_NULL; + } + int32_t error = remote->SendRequest(QUERY_SINK_VERSION, data, reply, option); if (error != NO_ERROR) { DHLOGE("SendRequest failed, errCode = %d", error); return ERR_DH_FWK_SERVICE_IPC_SEND_REQUEST_FAIL; -- Gitee From 0695afa9fd5924b7130f559cce869d3148da1ecb Mon Sep 17 00:00:00 2001 From: tangfan <1824525929@qq.com> Date: Wed, 23 Mar 2022 17:38:16 +0800 Subject: [PATCH 2/2] fix null and enum Signed-off-by: tangfan <1824525929@qq.com> --- .../include/resourcemanager/capability_utils.h | 2 +- .../src/componentloader/component_loader.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/services/distributedhardwarefwkserviceimpl/include/resourcemanager/capability_utils.h b/services/distributedhardwarefwkserviceimpl/include/resourcemanager/capability_utils.h index 03ba810c..f6e39085 100644 --- a/services/distributedhardwarefwkserviceimpl/include/resourcemanager/capability_utils.h +++ b/services/distributedhardwarefwkserviceimpl/include/resourcemanager/capability_utils.h @@ -23,7 +23,7 @@ namespace OHOS { namespace DistributedHardware { -enum CapabilityInfoFilter : uint32_t { +enum class CapabilityInfoFilter : uint32_t { FILTER_DH_ID = 0, FILTER_DEVICE_ID = 1, FILTER_DEVICE_NAME = 2, diff --git a/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp index 10d940b1..604f5dd6 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp @@ -131,7 +131,7 @@ void *ComponentLoader::GetHandler(const std::string &soName) return nullptr; } char path[PATH_MAX + 1] = {0x00}; - if (soName.length() == 0 || soName.length() > PATH_MAX || realpath(soName.c_str(), path) == NULL) { + if (soName.length() == 0 || soName.length() > PATH_MAX || realpath(soName.c_str(), path) == nullptr) { DHLOGE("File canonicalization failed"); return nullptr; } -- Gitee