diff --git a/common/log/include/distributed_hardware_log.h b/common/log/include/distributed_hardware_log.h index 0a2bdfda67952e6ee30d5b8871d5aca936be75e1..51c06a5614e8c65c52eab776de7f67c0b8627820 100644 --- a/common/log/include/distributed_hardware_log.h +++ b/common/log/include/distributed_hardware_log.h @@ -33,6 +33,6 @@ namespace DistributedHardware { #define DHLOGE(fmt, ...) DHLog(DH_LOG_ERROR, \ (std::string("[") + DH_LOG_TAG + "][" + __FUNCTION__ + "]:" + fmt).c_str(), ##__VA_ARGS__) -} -} -#endif \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS +#endif diff --git a/common/utils/include/constants.h b/common/utils/include/constants.h index a6aefea5389c4b6586c348a51e42e71deb9a1067..37b1dfa6f0edaf12eeed62337ae408d884d4e98c 100644 --- a/common/utils/include/constants.h +++ b/common/utils/include/constants.h @@ -42,6 +42,6 @@ namespace DistributedHardware { const std::string DH_COMPONENT_TYPE = "dhType"; const std::string DH_COMPONENT_SINK_VER = "version"; const std::string DH_COMPONENT_DEFAULT_VERSION = "1.0"; -} -} -#endif \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS +#endif diff --git a/common/utils/include/device_type.h b/common/utils/include/device_type.h index f4b8a9cc25f18e63df62ce85944bf08202d0269c..03a4f819008da594d1c704eb4dfcd0c4bcd29237 100644 --- a/common/utils/include/device_type.h +++ b/common/utils/include/device_type.h @@ -44,6 +44,6 @@ struct DeviceInfo { explicit DeviceInfo(std::string uuid, std::string deviceId, std::string deviceName, uint16_t deviceType) : uuid(uuid), deviceId(deviceId), deviceName(deviceName), deviceType(deviceType) {} }; -} -} -#endif \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS +#endif diff --git a/common/utils/include/distributed_hardware_errno.h b/common/utils/include/distributed_hardware_errno.h index beb2e5427fe5d67144ed3b665f6f06302ec1e2a4..2bab94971f8c7c74dbaab52cd959ee6a539b6d1c 100644 --- a/common/utils/include/distributed_hardware_errno.h +++ b/common/utils/include/distributed_hardware_errno.h @@ -88,6 +88,6 @@ namespace DistributedHardware { constexpr int32_t ERR_DH_FWK_ACCESS_UNINIT_DM_FAILED = -10901; constexpr int32_t ERR_DH_FWK_ACCESS_REGISTER_DM_FAILED = -10902; constexpr int32_t ERR_DH_FWK_ACCESS_UNREGISTER_DM_FAILED = -10903; -} -} +} // namespace DistributedHardware +} // namespace OHOS #endif diff --git a/common/utils/include/idistributed_hardware.h b/common/utils/include/idistributed_hardware.h index 16a6181c3e3707647ec3e1923047bf03290865c0..c0db431881465a385b768bd1c103b6f335e43791 100644 --- a/common/utils/include/idistributed_hardware.h +++ b/common/utils/include/idistributed_hardware.h @@ -35,6 +35,6 @@ public: QUERY_SINK_VERSION = 1 }; }; -} -} -#endif \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS +#endif diff --git a/common/utils/include/idistributed_hardware_manager.h b/common/utils/include/idistributed_hardware_manager.h index 016689beb091d8ed86ca9d5eab86a22a3b8d6ab8..aed2954f353757cc33e81624c119fecc130cc70f 100644 --- a/common/utils/include/idistributed_hardware_manager.h +++ b/common/utils/include/idistributed_hardware_manager.h @@ -25,7 +25,7 @@ namespace OHOS { namespace DistributedHardware { class IDistributedHardwareManager { public: - virtual ~IDistributedHardwareManager() {}; + virtual ~IDistributedHardwareManager() {} virtual int32_t Initialize() = 0; virtual int32_t Release() = 0; virtual int32_t SendOnLineEvent(const std::string &networkId, const std::string &uuid, @@ -35,6 +35,6 @@ public: virtual size_t GetOnLineCount() = 0; virtual int32_t GetComponentVersion(std::unordered_map &versionMap) = 0; }; -} -} +} // namespace DistributedHardware +} // namespace OHOS #endif diff --git a/common/utils/include/idistributed_hardware_sink.h b/common/utils/include/idistributed_hardware_sink.h index 1947022f6da4bfa88d0299cf20d2250369864ea0..0b36e0f5a57f21810b89324a1e17c31ddae8bd38 100644 --- a/common/utils/include/idistributed_hardware_sink.h +++ b/common/utils/include/idistributed_hardware_sink.h @@ -34,6 +34,6 @@ public: virtual int32_t UnsubscribeLocalHardware(const std::string &dhId) = 0; }; extern "C" __attribute__((visibility("default"))) IDistributedHardwareSink* GetSinkHardwareHandler(); -} -} -#endif \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS +#endif diff --git a/common/utils/include/idistributed_hardware_source.h b/common/utils/include/idistributed_hardware_source.h index 00a326852426ea7c447baa879fd547b8da5953c9..8a9b0354acddba284995ea4ba069e7dbf8e1c7d3 100644 --- a/common/utils/include/idistributed_hardware_source.h +++ b/common/utils/include/idistributed_hardware_source.h @@ -51,6 +51,6 @@ public: const std::string &value) = 0; }; extern "C" __attribute__((visibility("default"))) IDistributedHardwareSource* GetSourceHardwareHandler(); -} -} -#endif \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS +#endif diff --git a/common/utils/include/ihardware_handler.h b/common/utils/include/ihardware_handler.h index 3f8f0cf70f30ee8b9f04422ae37ef0c53841b18e..e98caf3cce4512da7e7c5a9125e7b3ebaa72b80f 100644 --- a/common/utils/include/ihardware_handler.h +++ b/common/utils/include/ihardware_handler.h @@ -44,6 +44,6 @@ public: virtual void RegisterPluginListener(std::shared_ptr listener) = 0; }; extern "C" __attribute__((visibility("default"))) IHardwareHandler* GetHardwareHandler(); -} -} -#endif \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS +#endif diff --git a/common/utils/include/single_instance.h b/common/utils/include/single_instance.h index 5cf872555b7555fc07f6c645da55a92553ecea24..78da97ce7a495a383adbdfb7b1f46b1bbfc9d493 100644 --- a/common/utils/include/single_instance.h +++ b/common/utils/include/single_instance.h @@ -39,6 +39,6 @@ className & className::GetInstance() \ static className instance; \ return instance; \ } -} -} -#endif \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS +#endif diff --git a/services/distributedhardwarefwkservice/include/accessmanager/access_manager.h b/services/distributedhardwarefwkservice/include/accessmanager/access_manager.h index 8d670a44639c255f23b99094ffe267d29c238a29..5156dcbb9106343fa3b508dd21ad9b02d8f8a841 100644 --- a/services/distributedhardwarefwkservice/include/accessmanager/access_manager.h +++ b/services/distributedhardwarefwkservice/include/accessmanager/access_manager.h @@ -60,6 +60,6 @@ private: std::mutex accessMutex_; }; -} -} +} // namespace DistributedHardware +} // namespace OHOS #endif diff --git a/services/distributedhardwarefwkservice/include/distributed_hardware_manager_factory.h b/services/distributedhardwarefwkservice/include/distributed_hardware_manager_factory.h index 850a5f27e81557900ab355d80093058ef7bf2f43..7c9ba448d1a9b0029cee8396964cfe814c8378cd 100644 --- a/services/distributedhardwarefwkservice/include/distributed_hardware_manager_factory.h +++ b/services/distributedhardwarefwkservice/include/distributed_hardware_manager_factory.h @@ -43,6 +43,6 @@ private: IDistributedHardwareManager *distributedHardwareMgrPtr_ { nullptr }; std::mutex mutex_; }; -} -} -#endif \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS +#endif diff --git a/services/distributedhardwarefwkservice/include/distributed_hardware_service.h b/services/distributedhardwarefwkservice/include/distributed_hardware_service.h index fe82313cc024544ffae4669fa3ecbf744d1dc031..8f91391af76db508af8fb2404e534b8f6f1dcea3 100644 --- a/services/distributedhardwarefwkservice/include/distributed_hardware_service.h +++ b/services/distributedhardwarefwkservice/include/distributed_hardware_service.h @@ -47,6 +47,6 @@ private: bool registerToService_ = false; ServiceRunningState state_ = ServiceRunningState::STATE_NOT_START; }; -} -} -#endif \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS +#endif diff --git a/services/distributedhardwarefwkservice/include/distributed_hardware_stub.h b/services/distributedhardwarefwkservice/include/distributed_hardware_stub.h index 464e5f136f496f787d387aa64a8bf3289cbc072b..80d1d2685186d614168ef2eacce9f744ace7a9ce 100644 --- a/services/distributedhardwarefwkservice/include/distributed_hardware_stub.h +++ b/services/distributedhardwarefwkservice/include/distributed_hardware_stub.h @@ -26,5 +26,5 @@ public: private: std::string ToJson(const std::unordered_map &versionMap) const; }; -} -} \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS diff --git a/services/distributedhardwarefwkservice/src/accessmanager/access_manager.cpp b/services/distributedhardwarefwkservice/src/accessmanager/access_manager.cpp index 26a2e01209f1fd62b7cff7a926bb1a72563dae93..e9ecf2eb892afb50f3edef4ff8858e2cc78c978c 100644 --- a/services/distributedhardwarefwkservice/src/accessmanager/access_manager.cpp +++ b/services/distributedhardwarefwkservice/src/accessmanager/access_manager.cpp @@ -39,7 +39,11 @@ AccessManager::~AccessManager() std::shared_ptr AccessManager::GetInstance() { - static std::shared_ptr instance(new AccessManager); + static std::shared_ptr instance(new(std::nothrow) AccessManager); + if (instance == nullptr) { + DHLOGE("instance is nullptr, because applying memory fail!"); + return nullptr; + } return instance; } @@ -162,5 +166,5 @@ void AccessManager::SendTrustedDeviceOnline() DistributedHardwareManagerFactory::GetInstance().SendOnLineEvent(networkId, uuid, deviceInfo.deviceTypeId); } } -} -} +} // namespace DistributedHardware +} // namespace OHOS diff --git a/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp b/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp index 0a4dda09cc318de297f170377fb7272522521c62..dea13812c7fc113f62e843629c43439f400657a1 100644 --- a/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp +++ b/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp @@ -186,5 +186,5 @@ int32_t DistributedHardwareManagerFactory::GetComponentVersion(std::unordered_ma } return distributedHardwareMgrPtr_->GetComponentVersion(versionMap); } -} -} +} // namespace DistributedHardware +} // namespace OHOS diff --git a/services/distributedhardwarefwkservice/src/distributed_hardware_service.cpp b/services/distributedhardwarefwkservice/src/distributed_hardware_service.cpp index cc28e1f8b0de5dc4558fb1a71d051c200fd17736..773c243451a6a850967adf56f612bbfe1293f4ea 100644 --- a/services/distributedhardwarefwkservice/src/distributed_hardware_service.cpp +++ b/services/distributedhardwarefwkservice/src/distributed_hardware_service.cpp @@ -82,5 +82,5 @@ int32_t DistributedHardwareService::QuerySinkVersion(std::unordered_map compHandlerMap_; std::atomic isLocalVersionInit_; }; -} -} +} // namespace DistributedHardware +} // namespace OHOS #endif diff --git a/services/distributedhardwarefwkserviceimpl/include/componentmanager/component_disable.h b/services/distributedhardwarefwkserviceimpl/include/componentmanager/component_disable.h index 5301d0d693abb2eb9880d249c3923bd2d51db0a8..a59b0da47c758dcf51cff5fbf72d841269abbd0b 100644 --- a/services/distributedhardwarefwkserviceimpl/include/componentmanager/component_disable.h +++ b/services/distributedhardwarefwkserviceimpl/include/componentmanager/component_disable.h @@ -37,6 +37,6 @@ private: std::mutex mutex_; std::condition_variable conVar_; }; -} -} +} // namespace DistributedHardware +} // namespace OHOS #endif diff --git a/services/distributedhardwarefwkserviceimpl/include/componentmanager/component_enable.h b/services/distributedhardwarefwkserviceimpl/include/componentmanager/component_enable.h index 83a0602c1d08135fa07cd14b7ce37d3ec448f3bc..4569ecfe689880b80fbb0df5b7d52a751f0eb748 100644 --- a/services/distributedhardwarefwkserviceimpl/include/componentmanager/component_enable.h +++ b/services/distributedhardwarefwkserviceimpl/include/componentmanager/component_enable.h @@ -37,6 +37,6 @@ private: std::mutex mutex_; std::condition_variable conVar_; }; -} -} +} // namespace DistributedHardware +} // namespace OHOS #endif diff --git a/services/distributedhardwarefwkserviceimpl/include/componentmanager/component_manager.h b/services/distributedhardwarefwkserviceimpl/include/componentmanager/component_manager.h index 463f123f5b29e51ba3351c442cc66e3fbe929afd..706f0e2127c6231ad2c3d2077d5c3add7f24332c 100644 --- a/services/distributedhardwarefwkserviceimpl/include/componentmanager/component_manager.h +++ b/services/distributedhardwarefwkserviceimpl/include/componentmanager/component_manager.h @@ -73,6 +73,6 @@ private: std::unordered_map> sinkVersions_; std::mutex sinkVersionMutex_; }; -} -} +} // namespace DistributedHardware +} // namespace OHOS #endif diff --git a/services/distributedhardwarefwkserviceimpl/include/distributed_hardware_manager.h b/services/distributedhardwarefwkserviceimpl/include/distributed_hardware_manager.h index 07bec4f887f2643afc48dbfafa993839c77df22f..77f92f6de4e509675b93f91e80f1174c5570ef75 100644 --- a/services/distributedhardwarefwkserviceimpl/include/distributed_hardware_manager.h +++ b/services/distributedhardwarefwkserviceimpl/include/distributed_hardware_manager.h @@ -32,6 +32,6 @@ public: size_t GetOnLineCount() override; int32_t GetComponentVersion(std::unordered_map &versionMap) override; }; -} -} -#endif \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS +#endif diff --git a/services/distributedhardwarefwkserviceimpl/include/distributed_hardware_proxy.h b/services/distributedhardwarefwkserviceimpl/include/distributed_hardware_proxy.h index d362558eaf6d0e66f2cae215fbbc5b39b696a2f1..13bea7e2ea169df21a5f923e804fc7ace51f6599 100644 --- a/services/distributedhardwarefwkserviceimpl/include/distributed_hardware_proxy.h +++ b/services/distributedhardwarefwkserviceimpl/include/distributed_hardware_proxy.h @@ -39,6 +39,6 @@ private: static inline BrokerDelegator delegator_; }; -} -} +} // namespace DistributedHardware +} // namespace OHOS #endif diff --git a/services/distributedhardwarefwkserviceimpl/include/localhardwaremanager/local_hardware_manager.h b/services/distributedhardwarefwkserviceimpl/include/localhardwaremanager/local_hardware_manager.h index d12c3e03f1518cac2fd421fe7070d2b3b620a001..0c90ba555f599146f9c63dfd6bcef603a42cd26f 100644 --- a/services/distributedhardwarefwkserviceimpl/include/localhardwaremanager/local_hardware_manager.h +++ b/services/distributedhardwarefwkserviceimpl/include/localhardwaremanager/local_hardware_manager.h @@ -47,6 +47,6 @@ private: private: std::map compToolFuncsMap_; }; -} -} +} // namespace DistributedHardware +} // namespace OHOS #endif diff --git a/services/distributedhardwarefwkserviceimpl/include/resourcemanager/capability_info.h b/services/distributedhardwarefwkserviceimpl/include/resourcemanager/capability_info.h index 6a461ab11b206734114dd8089d981c08c6427bf5..4bad08256ac929e2c9662c2bb0285a6f14213124 100644 --- a/services/distributedhardwarefwkserviceimpl/include/resourcemanager/capability_info.h +++ b/services/distributedhardwarefwkserviceimpl/include/resourcemanager/capability_info.h @@ -86,6 +86,6 @@ void ToJson(nlohmann::json &jsonObject, const CapabilityInfo &capability); void FromJson(const nlohmann::json &jsonObject, CapabilityInfo &capability); using CapabilityInfoMap = std::map>; -} -} +} // namespace DistributedHardware +} // namespace OHOS #endif diff --git a/services/distributedhardwarefwkserviceimpl/include/resourcemanager/capability_info_event.h b/services/distributedhardwarefwkserviceimpl/include/resourcemanager/capability_info_event.h index ba61aa14784aa383d84e492de3a62f57e5b048e1..762e296213b3e0d74d8c3526d1f389636600ad23 100644 --- a/services/distributedhardwarefwkserviceimpl/include/resourcemanager/capability_info_event.h +++ b/services/distributedhardwarefwkserviceimpl/include/resourcemanager/capability_info_event.h @@ -26,6 +26,7 @@ namespace OHOS { namespace DistributedHardware { class CapabilityInfoEvent : public Event { TYPEINDENT(CapabilityInfoEvent) + public: enum class EventType : uint32_t { UNDEFINED = 0, @@ -33,7 +34,7 @@ public: }; public: - CapabilityInfoEvent(EventSender &sender) : Event(sender) + explicit CapabilityInfoEvent(EventSender &sender) : Event(sender) { action_ = EventType::UNDEFINED; } @@ -50,6 +51,6 @@ public: private: EventType action_; }; -} -} +} // namespace DistributedHardware +} // namespace OHOS #endif diff --git a/services/distributedhardwarefwkserviceimpl/include/resourcemanager/capability_info_manager.h b/services/distributedhardwarefwkserviceimpl/include/resourcemanager/capability_info_manager.h index c9154d172aee49030ea9ac831029b2954d07cea6..bbbd9c269512dcc44afc7d0ab18cbda311f25350 100644 --- a/services/distributedhardwarefwkserviceimpl/include/resourcemanager/capability_info_manager.h +++ b/services/distributedhardwarefwkserviceimpl/include/resourcemanager/capability_info_manager.h @@ -104,6 +104,6 @@ private: std::shared_ptr dbAdapterPtr_; CapabilityInfoMap globalCapInfoMap_; }; -} -} -#endif \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS +#endif diff --git a/services/distributedhardwarefwkserviceimpl/include/resourcemanager/capability_utils.h b/services/distributedhardwarefwkserviceimpl/include/resourcemanager/capability_utils.h index 7bac49dd53a185c6a8d49316a568601fd41874cc..03ba810c7ce1f1d1fe84266c25a4c4e6c577a1bc 100644 --- a/services/distributedhardwarefwkserviceimpl/include/resourcemanager/capability_utils.h +++ b/services/distributedhardwarefwkserviceimpl/include/resourcemanager/capability_utils.h @@ -37,6 +37,6 @@ public: static std::string GetCapabilityKey(const std::string &deviceId, const std::string &dhId); static bool IsCapKeyMatchDeviceId(const std::string &key, const std::string &deviceId); }; -} -} +} // namespace DistributedHardware +} // namespace OHOS #endif diff --git a/services/distributedhardwarefwkserviceimpl/include/resourcemanager/db_adapter.h b/services/distributedhardwarefwkserviceimpl/include/resourcemanager/db_adapter.h index cc7ff2fbe2450e66109a968f45b9482bb1f53ef7..6a27272c1c3b157fecd3f7901454343a686de26d 100644 --- a/services/distributedhardwarefwkserviceimpl/include/resourcemanager/db_adapter.h +++ b/services/distributedhardwarefwkserviceimpl/include/resourcemanager/db_adapter.h @@ -84,6 +84,6 @@ private: std::mutex dbAdapterMutex_; std::unordered_map manualSyncCountMap_; }; -} -} -#endif \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS +#endif diff --git a/services/distributedhardwarefwkserviceimpl/include/task/disable_task.h b/services/distributedhardwarefwkserviceimpl/include/task/disable_task.h index 83276ac73026ea0d5a4b1a4fc2bed9da358313b4..5298235b44a622ce4f08d499f4bbc364eb59de40 100644 --- a/services/distributedhardwarefwkserviceimpl/include/task/disable_task.h +++ b/services/distributedhardwarefwkserviceimpl/include/task/disable_task.h @@ -32,6 +32,6 @@ private: int32_t UnRegisterHardware(); void DoTaskInner(); }; -} -} -#endif \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS +#endif diff --git a/services/distributedhardwarefwkserviceimpl/include/task/enable_task.h b/services/distributedhardwarefwkserviceimpl/include/task/enable_task.h index 8c2aae9988eaebe17ffa5ec70c7648e87acf9bde..55842ce3b50f31ad9c45f979c4a4f46303d48a79 100644 --- a/services/distributedhardwarefwkserviceimpl/include/task/enable_task.h +++ b/services/distributedhardwarefwkserviceimpl/include/task/enable_task.h @@ -32,6 +32,6 @@ private: int32_t RegisterHardware(); void DoTaskInner(); }; -} -} -#endif \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS +#endif diff --git a/services/distributedhardwarefwkserviceimpl/include/task/offline_task.h b/services/distributedhardwarefwkserviceimpl/include/task/offline_task.h index cfcd34a45f9c1d0e007b8f28da5a92dbab37fc98..adb2ecdcfb35a65faa1506baacfc85a7c0c8fcdc 100644 --- a/services/distributedhardwarefwkserviceimpl/include/task/offline_task.h +++ b/services/distributedhardwarefwkserviceimpl/include/task/offline_task.h @@ -48,6 +48,6 @@ private: std::mutex unFinishTaskMtx_; std::set unFinishChildrenTasks_; }; -} -} +} // namespace DistributedHardware +} // namespace OHOS #endif diff --git a/services/distributedhardwarefwkserviceimpl/include/task/online_task.h b/services/distributedhardwarefwkserviceimpl/include/task/online_task.h index d21d47b62486ee1fb45b981df59095eeca1f4618..6e9eead87b9b488096634507976cd17d35a4473f 100644 --- a/services/distributedhardwarefwkserviceimpl/include/task/online_task.h +++ b/services/distributedhardwarefwkserviceimpl/include/task/online_task.h @@ -31,6 +31,6 @@ private: void DoSyncInfo(); void CreateEnableTask(); }; -} -} -#endif \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS +#endif diff --git a/services/distributedhardwarefwkserviceimpl/include/task/task.h b/services/distributedhardwarefwkserviceimpl/include/task/task.h index de9117c24dc9b9af9e8e86cae47809dceff947c5..65a007cedfebc09f389d4e40112aba970c3062b2 100644 --- a/services/distributedhardwarefwkserviceimpl/include/task/task.h +++ b/services/distributedhardwarefwkserviceimpl/include/task/task.h @@ -65,6 +65,6 @@ private: TaskState taskState_ { TaskState::INIT }; }; -} -} -#endif \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS +#endif diff --git a/services/distributedhardwarefwkserviceimpl/include/task/task_board.h b/services/distributedhardwarefwkserviceimpl/include/task/task_board.h index 3a88cc22184883fb7dffeb3a1acfe43a2c65c7ac..d7ffaaceb7d882993b2fe6f9d61ea95f689ec996 100644 --- a/services/distributedhardwarefwkserviceimpl/include/task/task_board.h +++ b/services/distributedhardwarefwkserviceimpl/include/task/task_board.h @@ -43,6 +43,6 @@ private: std::mutex tasksMtx_; std::unordered_map> tasks_; }; -} -} -#endif \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS +#endif diff --git a/services/distributedhardwarefwkserviceimpl/include/task/task_executor.h b/services/distributedhardwarefwkserviceimpl/include/task/task_executor.h index 08fae4a22fa2c53ef7ae22fa40b0bdfedb57b001..08a0719264feb040d18b33b56575e940143139bf 100644 --- a/services/distributedhardwarefwkserviceimpl/include/task/task_executor.h +++ b/services/distributedhardwarefwkserviceimpl/include/task/task_executor.h @@ -42,6 +42,6 @@ private: std::condition_variable condVar_; bool taskThreadFlag_; }; -} -} -#endif \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS +#endif diff --git a/services/distributedhardwarefwkserviceimpl/include/task/task_factory.h b/services/distributedhardwarefwkserviceimpl/include/task/task_factory.h index 957d820e3885767683eb378d25467f01472779c4..90f519c4cc0ab292337eb2aa0348422ed24b8e49 100644 --- a/services/distributedhardwarefwkserviceimpl/include/task/task_factory.h +++ b/services/distributedhardwarefwkserviceimpl/include/task/task_factory.h @@ -29,6 +29,6 @@ public: std::shared_ptr CreateTask(TaskType taskType, const std::string &networkId, const std::string &uuid, const std::string &dhId, std::shared_ptr fatherTask); }; -} -} -#endif \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS +#endif diff --git a/services/distributedhardwarefwkserviceimpl/include/utils/dh_context.h b/services/distributedhardwarefwkserviceimpl/include/utils/dh_context.h index 42b1c825f54618cac51218bd0caedda21c8eab9d..d9132b931735bf0508f9fdf9f37ea904d43f597b 100644 --- a/services/distributedhardwarefwkserviceimpl/include/utils/dh_context.h +++ b/services/distributedhardwarefwkserviceimpl/include/utils/dh_context.h @@ -57,6 +57,6 @@ private: std::unordered_map deviceIdUUIDMap_; std::shared_mutex onlineDevMutex_; }; -} -} -#endif \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS +#endif diff --git a/services/distributedhardwarefwkserviceimpl/include/utils/impl_utils.h b/services/distributedhardwarefwkserviceimpl/include/utils/impl_utils.h index c29fd75c8a306581afac31b559ae2be4167614b8..ff549114aac83133b4a1b40a26a728c3161989ef 100644 --- a/services/distributedhardwarefwkserviceimpl/include/utils/impl_utils.h +++ b/services/distributedhardwarefwkserviceimpl/include/utils/impl_utils.h @@ -60,6 +60,6 @@ struct DHVersion { std::string dhVersion; std::unordered_map compVersions; }; -} -} -#endif \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS +#endif diff --git a/services/distributedhardwarefwkserviceimpl/include/versionmanager/version_manager.h b/services/distributedhardwarefwkserviceimpl/include/versionmanager/version_manager.h index 4071074a2be20716f8524d5e825508bdaf55566d..0626567add6c46c250f476ef07f4250f74005a03 100644 --- a/services/distributedhardwarefwkserviceimpl/include/versionmanager/version_manager.h +++ b/services/distributedhardwarefwkserviceimpl/include/versionmanager/version_manager.h @@ -47,6 +47,6 @@ private: std::unordered_map dhVersions_; std::mutex versionMutex_; }; -} -} -#endif \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS +#endif diff --git a/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp index 9d262bbb828b090002650d88e58e5bd3ea9e0253..10d940b1ee6e098e32096fcc16514debb397d084 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp @@ -318,5 +318,5 @@ bool ComponentLoader::IsDHTypeExist(DHType dhType) } return true; } -} -} \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS diff --git a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_disable.cpp b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_disable.cpp index 008cec9cb6a7bed91d58e38b4d9f46404b62bec7..9c53fab5385c61478d471887b3b7bbc16199d752 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_disable.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_disable.cpp @@ -72,5 +72,5 @@ int32_t ComponentDisable::OnUnregisterResult(const std::string &networkId, const conVar_.notify_all(); return status_; } -} -} +} // namespace DistributedHardware +} // namespace OHOS diff --git a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_enable.cpp b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_enable.cpp index 051bf0099e545c58a7f2bcac25b94ce4d9ef08f0..c5a3b433aa8bdac06606f5c92e89fada645ca8b5 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_enable.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_enable.cpp @@ -72,5 +72,5 @@ int32_t ComponentEnable::OnRegisterResult(const std::string &networkId, const st conVar_.notify_all(); return status_; } -} -} \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS diff --git a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp index 0e4271a97545a6d7b4eb697295a3cde000de741e..6df99ba6e4d4362d0137f00e8a8f6d860d443d14 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp @@ -384,5 +384,5 @@ sptr ComponentManager::GetRemoteDHMS(const std::string &ne } return iface_cast(object); } -} -} +} // namespace DistributedHardware +} // namespace OHOS diff --git a/services/distributedhardwarefwkserviceimpl/src/distributed_hardware_manager.cpp b/services/distributedhardwarefwkserviceimpl/src/distributed_hardware_manager.cpp index cce91398367c86ebbc743a28d43281dd056536ce..0e205d3ea579304619b94f87a11a298bb2cb28d2 100644 --- a/services/distributedhardwarefwkserviceimpl/src/distributed_hardware_manager.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/distributed_hardware_manager.cpp @@ -160,5 +160,5 @@ int32_t DistributedHardwareManager::GetComponentVersion(std::unordered_map DistributedHardwareProxy::FromJson(const { return nlohmann::json::parse(json).get>(); } -} -} +} // namespace DistributedHardware +} // namespace OHOS diff --git a/services/distributedhardwarefwkserviceimpl/src/localhardwaremanager/local_hardware_manager.cpp b/services/distributedhardwarefwkserviceimpl/src/localhardwaremanager/local_hardware_manager.cpp index c84599794ffc83f4f04ea69f63a63134bf80d34c..7b6f0f5dabd38d2c8dd9eca82fd49855400738f9 100644 --- a/services/distributedhardwarefwkserviceimpl/src/localhardwaremanager/local_hardware_manager.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/localhardwaremanager/local_hardware_manager.cpp @@ -97,5 +97,5 @@ void LocalHardwareManager::AddLocalCapabilityInfo(const std::vector &dhI } CapabilityInfoManager::GetInstance()->AddCapability(capabilityInfos); } -} -} +} // namespace DistributedHardware +} // namespace OHOS diff --git a/services/distributedhardwarefwkserviceimpl/src/resourcemanager/capability_info.cpp b/services/distributedhardwarefwkserviceimpl/src/resourcemanager/capability_info.cpp index 317822445aa63c4d54adeea5ed9ef72ed5f45767..e510931945fef38032c4127de2300c8d1f183aaa 100644 --- a/services/distributedhardwarefwkserviceimpl/src/resourcemanager/capability_info.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/resourcemanager/capability_info.cpp @@ -151,5 +151,5 @@ void FromJson(const nlohmann::json &jsonObject, CapabilityInfo &capability) capability.SetDHAttrs(jsonObject.at(DH_ATTRS).get()); } } -} -} +} // namespace DistributedHardware +} // namespace OHOS diff --git a/services/distributedhardwarefwkserviceimpl/src/resourcemanager/capability_info_manager.cpp b/services/distributedhardwarefwkserviceimpl/src/resourcemanager/capability_info_manager.cpp index bfe9077f136934c558a7da12d7cedf31092ed345..d70a9270f9879c753353ed219356724b4ac59776 100644 --- a/services/distributedhardwarefwkserviceimpl/src/resourcemanager/capability_info_manager.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/resourcemanager/capability_info_manager.cpp @@ -43,7 +43,11 @@ CapabilityInfoManager::~CapabilityInfoManager() std::shared_ptr CapabilityInfoManager::GetInstance() { - static std::shared_ptr instance(new CapabilityInfoManager); + static std::shared_ptr instance(new(std::nothrow) CapabilityInfoManager); + if (instance == nullptr) { + DHLOGE("instance is nullptr, because applying memory fail!"); + return nullptr; + } return instance; } @@ -508,5 +512,5 @@ int32_t CapabilityInfoManager::GetDataByKeyPrefix(const std::string &keyPrefix, } return DH_FWK_SUCCESS; } -} -} +} // namespace DistributedHardware +} // namespace OHOS diff --git a/services/distributedhardwarefwkserviceimpl/src/resourcemanager/capability_utils.cpp b/services/distributedhardwarefwkserviceimpl/src/resourcemanager/capability_utils.cpp index c70f713a49e86d7cf1620d45e00a487ecb2a0e8e..450df0e91032f21ad058d89496cd192024285515 100644 --- a/services/distributedhardwarefwkserviceimpl/src/resourcemanager/capability_utils.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/resourcemanager/capability_utils.cpp @@ -46,5 +46,5 @@ bool CapabilityUtils::IsCapKeyMatchDeviceId(const std::string &key, const std::s std::string keyDevId = key.substr(0, separatorPos); return keyDevId.compare(deviceId) == 0; } -} -} \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS diff --git a/services/distributedhardwarefwkserviceimpl/src/resourcemanager/db_adapter.cpp b/services/distributedhardwarefwkserviceimpl/src/resourcemanager/db_adapter.cpp index 02e738e9ba5284a773a8889fc285964376c02d97..092d2dab4a374e71b1f1512bc20dc176c5a30850 100644 --- a/services/distributedhardwarefwkserviceimpl/src/resourcemanager/db_adapter.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/resourcemanager/db_adapter.cpp @@ -397,5 +397,5 @@ int32_t DBAdapter::RemoveDataByKey(const std::string &key) DHLOGD("Remove data by key success"); return DH_FWK_SUCCESS; } -} -} +} // namespace DistributedHardware +} // namespace OHOS diff --git a/services/distributedhardwarefwkserviceimpl/src/task/disable_task.cpp b/services/distributedhardwarefwkserviceimpl/src/task/disable_task.cpp index c852ad28fefcd7ef5a1eee7181c702e0778ceee0..11a23449e4849b2d227b750847ecdf707d291e84 100644 --- a/services/distributedhardwarefwkserviceimpl/src/task/disable_task.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/task/disable_task.cpp @@ -73,5 +73,5 @@ int32_t DisableTask::UnRegisterHardware() GetId().c_str(), GetAnonyString(GetUUID()).c_str(), GetDhId().c_str()); return result; } -} -} \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS diff --git a/services/distributedhardwarefwkserviceimpl/src/task/enable_task.cpp b/services/distributedhardwarefwkserviceimpl/src/task/enable_task.cpp index cd120a763cf6b57212ae8dc221444f5bda4ed1fa..536986d9e4e88cb8367d8d167d4435aca71aec2f 100644 --- a/services/distributedhardwarefwkserviceimpl/src/task/enable_task.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/task/enable_task.cpp @@ -62,5 +62,5 @@ int32_t EnableTask::RegisterHardware() GetId().c_str(), GetAnonyString(GetUUID()).c_str(), GetDhId().c_str()); return result; } -} -} \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS diff --git a/services/distributedhardwarefwkserviceimpl/src/task/offline_task.cpp b/services/distributedhardwarefwkserviceimpl/src/task/offline_task.cpp index c0c431481d375a6961d804befae2f68faa1a9024..a7875fb12ffa6290c16c41625d2716e569eb2283 100644 --- a/services/distributedhardwarefwkserviceimpl/src/task/offline_task.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/task/offline_task.cpp @@ -130,5 +130,5 @@ void OffLineTask::AddChildrenTask(std::shared_ptr childrenTask) std::lock_guard lock(unFinishTaskMtx_); this->unFinishChildrenTasks_.insert(childrenTask->GetId()); } -} -} \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS diff --git a/services/distributedhardwarefwkserviceimpl/src/task/online_task.cpp b/services/distributedhardwarefwkserviceimpl/src/task/online_task.cpp index 52f9b5403358d68b24337c74f512faac73ce0e75..0b4b5db11a7c31fd9c348d795edd90d4d703d784 100644 --- a/services/distributedhardwarefwkserviceimpl/src/task/online_task.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/task/online_task.cpp @@ -99,5 +99,5 @@ void OnLineTask::CreateEnableTask() TaskExecutor::GetInstance().PushTask(task); } } -} -} \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS diff --git a/services/distributedhardwarefwkserviceimpl/src/task/task.cpp b/services/distributedhardwarefwkserviceimpl/src/task/task.cpp index 349f645c9251bd29d937dacee7bd4da349ecc4e5..d5f789654e40ec19765c8e7b9ad194c51f274d1c 100644 --- a/services/distributedhardwarefwkserviceimpl/src/task/task.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/task/task.cpp @@ -100,5 +100,5 @@ void Task::SetFatherTask(std::shared_ptr fatherTask) { this->fatherTask_ = fatherTask; } -} -} \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS diff --git a/services/distributedhardwarefwkserviceimpl/src/task/task_board.cpp b/services/distributedhardwarefwkserviceimpl/src/task/task_board.cpp index 1d9decaedfa9a408869836ef8c665a4c196c24c1..93ba6f0d788be37b099b60b30a2833f28ff4f27b 100644 --- a/services/distributedhardwarefwkserviceimpl/src/task/task_board.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/task/task_board.cpp @@ -85,5 +85,5 @@ void TaskBoard::RemoveTaskInner(std::string taskId) tasks_.erase(taskId); } -} -} +} // namespace DistributedHardware +} // namespace OHOS diff --git a/services/distributedhardwarefwkserviceimpl/src/task/task_executor.cpp b/services/distributedhardwarefwkserviceimpl/src/task/task_executor.cpp index aa2c600765272a2ea54c2b4f52cfae18dd565158..45316ea519326b415b54a774e9d0d7aa7345a9fc 100644 --- a/services/distributedhardwarefwkserviceimpl/src/task/task_executor.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/task/task_executor.cpp @@ -87,5 +87,5 @@ void TaskExecutor::TriggerTask() DHContext::GetInstance().GetEventBus()->PostTask(taskFunc, task->GetId()); } } -} -} \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS diff --git a/services/distributedhardwarefwkserviceimpl/src/task/task_factory.cpp b/services/distributedhardwarefwkserviceimpl/src/task/task_factory.cpp index ba13f0f371c926f7363a0701a5c194fc4caaeb42..bb84623c343c76ebbaeb12de969046c95055b2ed 100644 --- a/services/distributedhardwarefwkserviceimpl/src/task/task_factory.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/task/task_factory.cpp @@ -66,5 +66,5 @@ std::shared_ptr TaskFactory::CreateTask(TaskType taskType, const std::stri return task; } -} -} \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS diff --git a/services/distributedhardwarefwkserviceimpl/src/utils/dh_context.cpp b/services/distributedhardwarefwkserviceimpl/src/utils/dh_context.cpp index 06e71cd186513ae9f376fea6e460f50c34af7808..63f6eb49180573e78e3f723c20797b148b3e433a 100644 --- a/services/distributedhardwarefwkserviceimpl/src/utils/dh_context.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/utils/dh_context.cpp @@ -97,5 +97,5 @@ std::string DHContext::GetUUIDByDeviceId(const std::string &deviceId) } return deviceIdUUIDMap_[deviceId]; } -} -} +} // namespace DistributedHardware +} // namespace OHOS diff --git a/services/distributedhardwarefwkserviceimpl/src/versionmanager/version_manager.cpp b/services/distributedhardwarefwkserviceimpl/src/versionmanager/version_manager.cpp index febd7d55375e2ecb8a1bf0281734a3d1f73d7262..c965b41331a2d43b718e339394dbf4234656fd8b 100644 --- a/services/distributedhardwarefwkserviceimpl/src/versionmanager/version_manager.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/versionmanager/version_manager.cpp @@ -112,5 +112,5 @@ std::string VersionManager::GetLocalDeviceVersion() { return DH_LOCAL_VERSION; } -} -} +} // namespace DistributedHardware +} // namespace OHOS diff --git a/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentloader/include/component_loader_test.h b/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentloader/include/component_loader_test.h index a5b422cecdce0afe7537de254abcd39e17d38923..a606eca7859a2c9ad5bb898b42a37cb339808e34 100644 --- a/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentloader/include/component_loader_test.h +++ b/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentloader/include/component_loader_test.h @@ -27,6 +27,6 @@ public: void SetUp(); void TearDown(); }; -} -} -#endif \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS +#endif diff --git a/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentloader/src/component_loader_test.cpp b/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentloader/src/component_loader_test.cpp index 4b47f1fbb364edb2560524455d98bd97229dc44a..6e7c858910da915d3b6766544a661100ac7e5cdb 100644 --- a/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentloader/src/component_loader_test.cpp +++ b/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentloader/src/component_loader_test.cpp @@ -148,5 +148,5 @@ HWTEST_F(ComponentLoaderTest, component_loader_test_007, TestSize.Level0) EXPECT_TRUE(ComponentLoader::GetInstance().compHandlerMap_[iter.first].sinkHandler == nullptr); } } -} -} +} // namespace DistributedHardware +} // namespace OHOS diff --git a/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentmanager/include/component_manager_test.h b/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentmanager/include/component_manager_test.h index 50046e78adb25cd9d85cb16173cdd3b164e0ac5c..2caeca7abad2c417faeb7a686aa5aabb7b17314f 100644 --- a/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentmanager/include/component_manager_test.h +++ b/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentmanager/include/component_manager_test.h @@ -29,6 +29,6 @@ public: int32_t Enable(int32_t timeout, int32_t status); int32_t Disable(int32_t timeout, int32_t status); }; -} -} -#endif \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS +#endif diff --git a/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentmanager/include/mock_idistributed_hardware_sink.h b/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentmanager/include/mock_idistributed_hardware_sink.h index 350aa76083a0d34af6a2f3019da8b41700991bdf..d61ebacbfc7e250d064c9a140f1e8695ccd82ef8 100644 --- a/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentmanager/include/mock_idistributed_hardware_sink.h +++ b/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentmanager/include/mock_idistributed_hardware_sink.h @@ -39,6 +39,6 @@ public: return 0; } }; -} -} -#endif \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS +#endif diff --git a/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentmanager/include/mock_idistributed_hardware_source.h b/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentmanager/include/mock_idistributed_hardware_source.h index cd7a35c9f78f6a9c0a8698a545d8c1f20b21d609..1d6cb662cbf59c7f30fc97fbb063d9d0e956f484 100644 --- a/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentmanager/include/mock_idistributed_hardware_source.h +++ b/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentmanager/include/mock_idistributed_hardware_source.h @@ -39,6 +39,6 @@ public: return 0; } }; -} -} -#endif \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS +#endif diff --git a/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentmanager/src/component_manager_test.cpp b/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentmanager/src/component_manager_test.cpp index 9c7714cf9d6f985c17bac9ed5f39259e1d24114b..b279b5063d7615ff245a75ce7a6670ca4b92b108 100644 --- a/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentmanager/src/component_manager_test.cpp +++ b/services/distributedhardwarefwkserviceimpl/test/unittest/common/componentmanager/src/component_manager_test.cpp @@ -339,5 +339,5 @@ HWTEST_F(ComponentManagerTest, disable_test_004, TestSize.Level0) thread5.join(); thread6.join(); } -} -} +} // namespace DistributedHardware +} // namespace OHOS diff --git a/services/distributedhardwarefwkserviceimpl/test/unittest/common/distributed_hardware_manager_test.cpp b/services/distributedhardwarefwkserviceimpl/test/unittest/common/distributed_hardware_manager_test.cpp index c01bae52b3d16074f545b0b7c485bcbb3f39c5ce..34c6bf24d53163da9f24f1826f6d0e47916ecbf5 100644 --- a/services/distributedhardwarefwkserviceimpl/test/unittest/common/distributed_hardware_manager_test.cpp +++ b/services/distributedhardwarefwkserviceimpl/test/unittest/common/distributed_hardware_manager_test.cpp @@ -168,5 +168,5 @@ HWTEST_F(DistributedHardwareManagerTest, sendOffLineEvent_test_003, TestSize.Lev ASSERT_EQ(DH_FWK_SUCCESS, TaskBoard::GetInstance().WaitForALLTaskFinish()); ASSERT_TRUE(TaskBoard::GetInstance().IsAllTaskFinish()); } -} -} +} // namespace DistributedHardware +} // namespace OHOS diff --git a/services/distributedhardwarefwkserviceimpl/test/unittest/common/distributed_hardware_manager_test.h b/services/distributedhardwarefwkserviceimpl/test/unittest/common/distributed_hardware_manager_test.h index 20fd1dd65ef848cd51ff218edca450e1a1a242a9..9d90f9ea40a27c7d56d30442f5ef02111e7c4d31 100644 --- a/services/distributedhardwarefwkserviceimpl/test/unittest/common/distributed_hardware_manager_test.h +++ b/services/distributedhardwarefwkserviceimpl/test/unittest/common/distributed_hardware_manager_test.h @@ -27,6 +27,6 @@ public: void SetUp(); void TearDown(); }; -} -} -#endif \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS +#endif diff --git a/services/distributedhardwarefwkserviceimpl/test/unittest/common/resourcemanager/include/resource_manager_test.h b/services/distributedhardwarefwkserviceimpl/test/unittest/common/resourcemanager/include/resource_manager_test.h index 63fecaccb2724b500311dec617b1f53a634c8d1b..7bcef9738da60e039486d36890e75a92c3d872e1 100644 --- a/services/distributedhardwarefwkserviceimpl/test/unittest/common/resourcemanager/include/resource_manager_test.h +++ b/services/distributedhardwarefwkserviceimpl/test/unittest/common/resourcemanager/include/resource_manager_test.h @@ -27,6 +27,6 @@ public: void SetUp(); void TearDown(); }; -} -} +} // namespace DistributedHardware +} // namespace OHOS #endif diff --git a/services/distributedhardwarefwkserviceimpl/test/unittest/common/resourcemanager/src/resource_manager_test.cpp b/services/distributedhardwarefwkserviceimpl/test/unittest/common/resourcemanager/src/resource_manager_test.cpp index 5a68c343340966e0ff9e216a08bbb9e6906ae868..86c4c5442d8623865e1086ee03f3ee717a200b0b 100644 --- a/services/distributedhardwarefwkserviceimpl/test/unittest/common/resourcemanager/src/resource_manager_test.cpp +++ b/services/distributedhardwarefwkserviceimpl/test/unittest/common/resourcemanager/src/resource_manager_test.cpp @@ -356,5 +356,5 @@ HWTEST_F(ResourceManagerTest, resource_manager_test_013, TestSize.Level0) DH_FWK_SUCCESS); EXPECT_EQ(capMap.size(), TEST_SIZE_10); } -} -} +} // namespace DistributedHardware +} // namespace OHOS diff --git a/services/distributedhardwarefwkserviceimpl/test/unittest/common/task/include/mock_disable_task.h b/services/distributedhardwarefwkserviceimpl/test/unittest/common/task/include/mock_disable_task.h index 39c45b3409032b425c7464df70d06c9b3d6136be..20d894dfc3e11333005a0d8d769865d5e3144e54 100644 --- a/services/distributedhardwarefwkserviceimpl/test/unittest/common/task/include/mock_disable_task.h +++ b/services/distributedhardwarefwkserviceimpl/test/unittest/common/task/include/mock_disable_task.h @@ -29,6 +29,6 @@ private: /* synchronous function for unregister distributed hardware, return on asynchronous unregister finish */ int32_t UnRegisterHardware(); }; -} -} -#endif \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS +#endif diff --git a/services/distributedhardwarefwkserviceimpl/test/unittest/common/task/include/mock_enable_task.h b/services/distributedhardwarefwkserviceimpl/test/unittest/common/task/include/mock_enable_task.h index abb35352689f1a956a3c8e7a24f9c59adcda9beb..de78236503376c295e7ee8e5b554e1276c20daa9 100644 --- a/services/distributedhardwarefwkserviceimpl/test/unittest/common/task/include/mock_enable_task.h +++ b/services/distributedhardwarefwkserviceimpl/test/unittest/common/task/include/mock_enable_task.h @@ -29,6 +29,6 @@ private: /* synchronous function for register distributed hardware, return on asynchronous register finish */ int32_t RegisterHardware(); }; -} -} -#endif \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS +#endif diff --git a/services/distributedhardwarefwkserviceimpl/test/unittest/common/task/include/mock_offline_task.h b/services/distributedhardwarefwkserviceimpl/test/unittest/common/task/include/mock_offline_task.h index 8f99e84607a1a30dea521e0bf7171172d9e84e6f..1ed33d2b735a9b189f1f28325ac26a29ddfda4f4 100644 --- a/services/distributedhardwarefwkserviceimpl/test/unittest/common/task/include/mock_offline_task.h +++ b/services/distributedhardwarefwkserviceimpl/test/unittest/common/task/include/mock_offline_task.h @@ -35,6 +35,6 @@ private: std::vector offLineDevInfos; }; -} -} -#endif \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS +#endif diff --git a/services/distributedhardwarefwkserviceimpl/test/unittest/common/task/include/mock_online_task.h b/services/distributedhardwarefwkserviceimpl/test/unittest/common/task/include/mock_online_task.h index 47cda4917f46fe1c76a3b61f79f9a8ef8797aef2..ea5351b813065aa28923327b8df09dfd3ed1fb41 100644 --- a/services/distributedhardwarefwkserviceimpl/test/unittest/common/task/include/mock_online_task.h +++ b/services/distributedhardwarefwkserviceimpl/test/unittest/common/task/include/mock_online_task.h @@ -35,6 +35,6 @@ private: std::vector onLineDevInfos; }; -} -} -#endif \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS +#endif diff --git a/services/distributedhardwarefwkserviceimpl/test/unittest/common/task/include/mock_task_factory.h b/services/distributedhardwarefwkserviceimpl/test/unittest/common/task/include/mock_task_factory.h index f97b9f9c43c08adb33dbddb6c4b015288b3eaa7e..f0e8612802ae162bba28626e944bd6e1c3605069 100644 --- a/services/distributedhardwarefwkserviceimpl/test/unittest/common/task/include/mock_task_factory.h +++ b/services/distributedhardwarefwkserviceimpl/test/unittest/common/task/include/mock_task_factory.h @@ -29,6 +29,6 @@ public: std::shared_ptr CreateTask(TaskType taskType, const std::string &networkId, const std::string &uuid, const std::string &dhId, std::shared_ptr fatherTask); }; -} -} -#endif \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS +#endif diff --git a/services/distributedhardwarefwkserviceimpl/test/unittest/common/task/include/mock_task_utils.h b/services/distributedhardwarefwkserviceimpl/test/unittest/common/task/include/mock_task_utils.h index 36fa6036d46fbe29ee28ee41ea349edf4a574d42..04b3da8b3aacf3fb3f2deb3148280b69f64d4ced 100644 --- a/services/distributedhardwarefwkserviceimpl/test/unittest/common/task/include/mock_task_utils.h +++ b/services/distributedhardwarefwkserviceimpl/test/unittest/common/task/include/mock_task_utils.h @@ -25,6 +25,6 @@ struct MockDevInfo { std::string uuid; std::string dhId; }; -} -} -#endif \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS +#endif diff --git a/services/distributedhardwarefwkserviceimpl/test/unittest/common/task/include/task_test.h b/services/distributedhardwarefwkserviceimpl/test/unittest/common/task/include/task_test.h index dc872f850d6f7a333d2a1f4bf01f42adad60a761..45edd92aa406f9973eafcc241a33ca3c7d6b48e1 100644 --- a/services/distributedhardwarefwkserviceimpl/test/unittest/common/task/include/task_test.h +++ b/services/distributedhardwarefwkserviceimpl/test/unittest/common/task/include/task_test.h @@ -27,6 +27,6 @@ public: void SetUp(); void TearDown(); }; -} -} -#endif \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS +#endif diff --git a/services/distributedhardwarefwkserviceimpl/test/unittest/common/task/src/mock_disable_task.cpp b/services/distributedhardwarefwkserviceimpl/test/unittest/common/task/src/mock_disable_task.cpp index 35a54724c90b1dd98043710086534c43a7355426..9beec548700120fc90b1b00887ec0b361c01330f 100644 --- a/services/distributedhardwarefwkserviceimpl/test/unittest/common/task/src/mock_disable_task.cpp +++ b/services/distributedhardwarefwkserviceimpl/test/unittest/common/task/src/mock_disable_task.cpp @@ -33,5 +33,5 @@ int32_t MockDisableTask::UnRegisterHardware() std::this_thread::sleep_for(200ms); return DH_FWK_SUCCESS; } -} -} \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS diff --git a/services/distributedhardwarefwkserviceimpl/test/unittest/common/task/src/mock_enable_task.cpp b/services/distributedhardwarefwkserviceimpl/test/unittest/common/task/src/mock_enable_task.cpp index dea92cc5ef97d1488727f453cbca631db46392c1..58e6586ae428237b7b653628bc56d147db191d57 100644 --- a/services/distributedhardwarefwkserviceimpl/test/unittest/common/task/src/mock_enable_task.cpp +++ b/services/distributedhardwarefwkserviceimpl/test/unittest/common/task/src/mock_enable_task.cpp @@ -32,5 +32,5 @@ int32_t MockEnableTask::RegisterHardware() std::this_thread::sleep_for(300ms); return DH_FWK_SUCCESS; } -} -} \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS diff --git a/services/distributedhardwarefwkserviceimpl/test/unittest/common/task/src/mock_offline_task.cpp b/services/distributedhardwarefwkserviceimpl/test/unittest/common/task/src/mock_offline_task.cpp index db577a7fb281ba2cd15e424a0286709be9bf6114..d514c646acf9e225bd3bd656afd60bd7dde67b5a 100644 --- a/services/distributedhardwarefwkserviceimpl/test/unittest/common/task/src/mock_offline_task.cpp +++ b/services/distributedhardwarefwkserviceimpl/test/unittest/common/task/src/mock_offline_task.cpp @@ -48,5 +48,5 @@ void MockOffLineTask::SetOffLineDevInfos(std::vector offLineDevInfo { this->offLineDevInfos = offLineDevInfos; } -} -} \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS diff --git a/services/distributedhardwarefwkserviceimpl/test/unittest/common/task/src/mock_online_task.cpp b/services/distributedhardwarefwkserviceimpl/test/unittest/common/task/src/mock_online_task.cpp index 815b00e4ede4a59211644340e23e0a2dee42c34a..310ce6823c5cf480b1a524c2fa8539aa3d0704bd 100644 --- a/services/distributedhardwarefwkserviceimpl/test/unittest/common/task/src/mock_online_task.cpp +++ b/services/distributedhardwarefwkserviceimpl/test/unittest/common/task/src/mock_online_task.cpp @@ -50,5 +50,5 @@ void MockOnLineTask::SetOnLineDevInfos(std::vector devInfos) { this->onLineDevInfos = devInfos; } -} -} \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS diff --git a/services/distributedhardwarefwkserviceimpl/test/unittest/common/task/src/mock_task_factory.cpp b/services/distributedhardwarefwkserviceimpl/test/unittest/common/task/src/mock_task_factory.cpp index d0a9d08c8def63571e7beb6967e7d5d385829fbf..479adaca2cbe77a472437c30531227abfe4971d6 100644 --- a/services/distributedhardwarefwkserviceimpl/test/unittest/common/task/src/mock_task_factory.cpp +++ b/services/distributedhardwarefwkserviceimpl/test/unittest/common/task/src/mock_task_factory.cpp @@ -60,5 +60,5 @@ std::shared_ptr MockTaskFactory::CreateTask(TaskType taskType, const std:: return task; } -} -} \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS diff --git a/services/distributedhardwarefwkserviceimpl/test/unittest/common/task/src/task_test.cpp b/services/distributedhardwarefwkserviceimpl/test/unittest/common/task/src/task_test.cpp index e5ee656788fdca9c517aef4a4e713a5a6a52e899..6f99d654e9130fbf1cc77d20e208a4cc8054c722 100644 --- a/services/distributedhardwarefwkserviceimpl/test/unittest/common/task/src/task_test.cpp +++ b/services/distributedhardwarefwkserviceimpl/test/unittest/common/task/src/task_test.cpp @@ -154,5 +154,5 @@ HWTEST_F(TaskTest, task_test_004, TestSize.Level0) ASSERT_EQ(DH_FWK_SUCCESS, TaskBoard::GetInstance().WaitForALLTaskFinish()); ASSERT_TRUE(TaskBoard::GetInstance().IsAllTaskFinish()); } -} -} \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS diff --git a/services/distributedhardwarefwkserviceimpl/test/unittest/common/versionmanager/include/version_manager_test.h b/services/distributedhardwarefwkserviceimpl/test/unittest/common/versionmanager/include/version_manager_test.h index 5a53290f4d151b8547e7b5b1f1e0f1ece40c0981..ac3e715a9eb82f785e152ef7ca3ad55c352d30e2 100644 --- a/services/distributedhardwarefwkserviceimpl/test/unittest/common/versionmanager/include/version_manager_test.h +++ b/services/distributedhardwarefwkserviceimpl/test/unittest/common/versionmanager/include/version_manager_test.h @@ -30,6 +30,6 @@ public: void SetUp(); void TearDown(); }; -} -} -#endif \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS +#endif diff --git a/services/distributedhardwarefwkserviceimpl/test/unittest/common/versionmanager/src/version_manager_test.cpp b/services/distributedhardwarefwkserviceimpl/test/unittest/common/versionmanager/src/version_manager_test.cpp index 12b68af18ed404402b6d7e1d5ff6ea11c2cadce8..874900c867654a98344e625b4d99ee7020f20567 100644 --- a/services/distributedhardwarefwkserviceimpl/test/unittest/common/versionmanager/src/version_manager_test.cpp +++ b/services/distributedhardwarefwkserviceimpl/test/unittest/common/versionmanager/src/version_manager_test.cpp @@ -154,5 +154,5 @@ HWTEST_F(VersionManagerTest, version_manager_test_005, TestSize.Level0) ret = VersionManager::GetInstance().RemoveDHVersion(TEST_DEVICE_ID_1); EXPECT_EQ(DH_FWK_SUCCESS, ret); } -} -} +} // namespace DistributedHardware +} // namespace OHOS diff --git a/utils/include/anonymous_string.h b/utils/include/anonymous_string.h index f2a88e0383121ff37b795ffcc0e10a298b85ef56..87fefb750c997954518bf9ae10339e71c2e0e73e 100644 --- a/utils/include/anonymous_string.h +++ b/utils/include/anonymous_string.h @@ -22,6 +22,6 @@ namespace OHOS { namespace DistributedHardware { std::string GetAnonyString(const std::string &value); std::string GetAnonyInt32(const int32_t value); -} -} -#endif \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS +#endif diff --git a/utils/include/dh_utils_tool.h b/utils/include/dh_utils_tool.h index 0fdf5b9ebbe89ca81ff9f7612261a0184b280587..cfcaf413fa8f87a3a14c1511bb8871f2f05ee57e 100644 --- a/utils/include/dh_utils_tool.h +++ b/utils/include/dh_utils_tool.h @@ -39,6 +39,6 @@ DeviceInfo GetLocalDeviceInfo(); /* Convert uuid to deviceId by sha256 encode */ std::string GetDeviceIdByUUID(const std::string &uuid); -} -} -#endif \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS +#endif diff --git a/utils/include/eventbus/event.h b/utils/include/eventbus/event.h index 8c9075345b08a6c4b349389b5848d0f02c692ffa..879e9e99e4313b28f86d1d7017e20ac907b3ea8c 100644 --- a/utils/include/eventbus/event.h +++ b/utils/include/eventbus/event.h @@ -32,7 +32,7 @@ class Event { TYPEINDENT(Event) public: - Event(EventSender &sender) : sender_(sender) {} + explicit Event(EventSender &sender) : sender_(sender) {} virtual ~Event() = default; @@ -44,6 +44,6 @@ public: private: EventSender &sender_; }; -} -} -#endif \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS +#endif diff --git a/utils/include/eventbus/event_bus.h b/utils/include/eventbus/event_bus.h index 2d1a9774ff192e47f519c792513e051932a9b4d4..4a4840dc1b8275beed399381fe15d65a9133fc10 100644 --- a/utils/include/eventbus/event_bus.h +++ b/utils/include/eventbus/event_bus.h @@ -63,7 +63,11 @@ public: Registrations *registrations = handlers[typeId]; if (registrations == nullptr) { - registrations = new EventRegistration::Registrations(); + registrations = new(std::nothrow) EventRegistration::Registrations(); + if (registrations == nullptr) { + ULOGE("registrations is null, because applying memory fail!"); + return nullptr; + } handlers[typeId] = registrations; } @@ -88,7 +92,11 @@ public: Registrations *registrations = handlers[typeId]; if (registrations == nullptr) { - registrations = new EventRegistration::Registrations(); + registrations = new(std::nothrow) EventRegistration::Registrations(); + if (registrations == nullptr) { + ULOGE("registrations is null, because applying memory fail!"); + return nullptr; + } handlers[typeId] = registrations; } @@ -201,6 +209,6 @@ private: using TypeMap = std::unordered_map> *>; TypeMap handlers; }; -} -} -#endif \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS +#endif diff --git a/utils/include/eventbus/event_registration.h b/utils/include/eventbus/event_registration.h index 623835ab3b334c6f2d512edc1543500af179b367..d726389fdd4698296172937eb7a6cffa9099644a 100644 --- a/utils/include/eventbus/event_registration.h +++ b/utils/include/eventbus/event_registration.h @@ -45,6 +45,6 @@ private: void * const handler; EventSender * const sender; }; -} -} -#endif \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS +#endif diff --git a/utils/include/eventbus/event_sender.h b/utils/include/eventbus/event_sender.h index 1aeaf29f0fcb0f2da08a5317cf196fa81aaef5de..72f3bc598621fb8dd3439a7b913326490adafdd5 100644 --- a/utils/include/eventbus/event_sender.h +++ b/utils/include/eventbus/event_sender.h @@ -22,6 +22,6 @@ class EventSender { public: virtual ~EventSender() = default; }; -} -} -#endif \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS +#endif diff --git a/utils/include/eventbus/eventbus_handler.h b/utils/include/eventbus/eventbus_handler.h index fb99b04c506109403e2153de945604a33548dab2..c7b702e0664786f77345794f02c0b360e589aeb8 100644 --- a/utils/include/eventbus/eventbus_handler.h +++ b/utils/include/eventbus/eventbus_handler.h @@ -34,6 +34,6 @@ public: OnEvent(e); } }; -} -} -#endif \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS +#endif diff --git a/utils/include/log/dh_log.h b/utils/include/log/dh_log.h index 94a39137ece5ed437c664744a3ff8900d5d6c4f7..0b38bb6e8f93c2d6976c9682572c09eb4d0f857d 100644 --- a/utils/include/log/dh_log.h +++ b/utils/include/log/dh_log.h @@ -38,6 +38,6 @@ void DHLog(DHLogLevel logLevel, const char *fmt, ...); #define ULOGE(fmt, ...) DHLog(DH_LOG_ERROR, \ (std::string("[") + DH_LOG_TAG + "][" + __FUNCTION__ + "]:" + fmt).c_str(), ##__VA_ARGS__) -} -} +} // namespace DistributedHardware +} // namespace OHOS #endif diff --git a/utils/src/anonymous_string.cpp b/utils/src/anonymous_string.cpp index 68597d7b40762cb68ce0ac498d3abb59e00f54cd..291fd9e9986a1b30dbc890d844ae6eae03b2d73f 100644 --- a/utils/src/anonymous_string.cpp +++ b/utils/src/anonymous_string.cpp @@ -64,5 +64,5 @@ std::string GetAnonyInt32(const int32_t value) std::string tempString(tempBuffer); return tempString; } -} -} +} // namespace DistributedHardware +} // namespace OHOS diff --git a/utils/src/dh_utils_tool.cpp b/utils/src/dh_utils_tool.cpp index ab5c3aecadc3fa9be83821321ae98f8820922b9e..e6e9f928c734a2007cd01c0b23c425028747a6af 100644 --- a/utils/src/dh_utils_tool.cpp +++ b/utils/src/dh_utils_tool.cpp @@ -115,5 +115,5 @@ DeviceInfo GetLocalDeviceInfo() devInfo.deviceType = info->deviceTypeId; return devInfo; } -} -} +} // namespace DistributedHardware +} // namespace OHOS diff --git a/utils/src/log/dh_log.cpp b/utils/src/log/dh_log.cpp index 16eb7c5f4a55869ef46fdb14ff1f5f71c4eac8d8..1ea885b6934ea50ad6365a3a1708e71a912291fe 100644 --- a/utils/src/log/dh_log.cpp +++ b/utils/src/log/dh_log.cpp @@ -83,5 +83,5 @@ void DHLog(DHLogLevel logLevel, const char *fmt, ...) } DHLogOut(logLevel, logBuf); } -} -} +} // namespace DistributedHardware +} // namespace OHOS diff --git a/utils/test/unittest/common/eventbus/BUILD.gn b/utils/test/unittest/common/eventbus/BUILD.gn index c3483808f510780fefd2dba488fa98f470fef3c3..ca74d2132bdd7c7dbae8ad73620819950816dbdc 100644 --- a/utils/test/unittest/common/eventbus/BUILD.gn +++ b/utils/test/unittest/common/eventbus/BUILD.gn @@ -12,13 +12,16 @@ # limitations under the License. import("//build/test.gni") -import("//foundation/distributedhardware/distributedhardwarefwk/distributedhardwarefwk.gni") +import( + "//foundation/distributedhardware/distributedhardwarefwk/distributedhardwarefwk.gni") + module_out_path = "distributed_hardware_fwk/event_bus_test" config("module_private_config") { visibility = [ ":*" ] include_dirs = [ "include", + "${common_path}/log/include", "${utils_path}/include", "${utils_path}/include/log", "${utils_path}/include/eventbus", @@ -35,13 +38,11 @@ ohos_unittest("EventBusTest") { configs = [ ":module_private_config" ] deps = [ + "//foundation/distributedhardware/distributedhardwarefwk/utils:distributedhardwareutils", "//third_party/googletest:gtest_main", - "//foundation/distributedhardware/distributedhardwarefwk/utils:distributedhardwareutils" ] - external_deps = [ - "eventhandler:libeventhandler", - ] + external_deps = [ "eventhandler:libeventhandler" ] } group("event_bus_test") { diff --git a/utils/test/unittest/common/eventbus/event_bus_test.cpp b/utils/test/unittest/common/eventbus/event_bus_test.cpp index 30d7a8135f2079a2ac201218ed21f520c94d1668..d0015d046587b79878a0d7e4e3279bbca48e6b52 100644 --- a/utils/test/unittest/common/eventbus/event_bus_test.cpp +++ b/utils/test/unittest/common/eventbus/event_bus_test.cpp @@ -13,6 +13,8 @@ * limitations under the License. */ +#include "distributed_hardware_log.h" + #include "event_bus_test.h" using namespace testing::ext; @@ -37,11 +39,27 @@ void EventbusTest::TearDownTestCase(void) void EventbusTest::SetUp() { - g_obj = new FakeObject("Player"); - g_listener = new FakeListener(); - g_sender = new FakeSender(); + g_obj = new(std::nothrow) FakeObject("Player"); + if (g_obj == nullptr) { + DHLOGE("obj is null, because applying memory fail!"); + return; + } + g_listener = new(std::nothrow) FakeListener(); + if (g_listener == nullptr) { + DHLOGE("listener is null, because applying memory fail!"); + return; + } + g_sender = new(std::nothrow) FakeSender(); + if (g_sender == nullptr) { + DHLOGE("sender is null, because applying memory fail!"); + return; + } g_regHandler = nullptr; - g_eventBus = new EventBus(); + g_eventBus = new(std::nothrow) EventBus(); + if (g_eventBus == nullptr) { + DHLOGE("eventBus is null, because applying memory fail!"); + return; + } } void EventbusTest::TearDown() @@ -155,5 +173,5 @@ HWTEST_F(EventbusTest, event_bus_test_005, TestSize.Level0) g_eventBus->PostEvent(e, POSTMODE::POST_SYNC); EXPECT_EQ(10, g_obj->GetAge()); } -} -} \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS diff --git a/utils/test/unittest/common/eventbus/event_bus_test.h b/utils/test/unittest/common/eventbus/event_bus_test.h index 110bfbb8f4670dab9c7dda1c2d54860b6a912d48..f3435a529c4da32332e1961b2facee90a7b4d91f 100644 --- a/utils/test/unittest/common/eventbus/event_bus_test.h +++ b/utils/test/unittest/common/eventbus/event_bus_test.h @@ -98,6 +98,6 @@ public: void SetUp(); void TearDown(); }; -} -} -#endif \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS +#endif diff --git a/utils/test/unittest/common/utilstool/utils_tool_test.cpp b/utils/test/unittest/common/utilstool/utils_tool_test.cpp index e67458ec24e8283b1a5e558221879daf6c90c371..d83b3356d2b15fe2ee75e3ef5c3792dce1aa0361 100644 --- a/utils/test/unittest/common/utilstool/utils_tool_test.cpp +++ b/utils/test/unittest/common/utilstool/utils_tool_test.cpp @@ -117,5 +117,5 @@ HWTEST_F(UtilsToolTest, utils_tool_test_004, TestSize.Level0) ASSERT_STRNE(std::to_string(i4).c_str(), GetAnonyInt32(i4).c_str()); ASSERT_STRNE(std::to_string(i5).c_str(), GetAnonyInt32(i5).c_str()); } -} -} \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS diff --git a/utils/test/unittest/common/utilstool/utils_tool_test.h b/utils/test/unittest/common/utilstool/utils_tool_test.h index 62926ab0b5ed9b8c0ae3fb1fdce2cfb9797a663f..234e06e05f7b717b49392066df728d8dd9216a3a 100644 --- a/utils/test/unittest/common/utilstool/utils_tool_test.h +++ b/utils/test/unittest/common/utilstool/utils_tool_test.h @@ -27,6 +27,6 @@ public: void SetUp(); void TearDown(); }; -} -} -#endif \ No newline at end of file +} // namespace DistributedHardware +} // namespace OHOS +#endif