diff --git a/services/distributedfiledaemon/include/device/device_info.h b/services/distributedfiledaemon/include/device/device_info.h index 0864dc2ccff40e48a71bd47796f1a37a1437c905..532455cdd6febb252e25a8bba77b7d6739973459 100644 --- a/services/distributedfiledaemon/include/device/device_info.h +++ b/services/distributedfiledaemon/include/device/device_info.h @@ -39,7 +39,7 @@ public: private: friend class DeviceManagerAgent; - std::atomic initCidFlag_{false}; + std::atomic initCidFlag_ { false }; std::string cid_; std::string udid_; }; diff --git a/services/distributedfiledaemon/include/ipc/daemon.h b/services/distributedfiledaemon/include/ipc/daemon.h index d5326ac4eb421d93cf53ee17f8a2b282e8bf1d06..a1a3ecc87bd46d6782c8a00c964e9e98635ff188 100644 --- a/services/distributedfiledaemon/include/ipc/daemon.h +++ b/services/distributedfiledaemon/include/ipc/daemon.h @@ -32,7 +32,7 @@ class Daemon final : public SystemAbility, public DaemonStub, protected NoCopyab DECLARE_SYSTEM_ABILITY(Daemon); public: - explicit Daemon(int32_t saID, bool runOnCreate = true) : SystemAbility(saID, runOnCreate){}; + explicit Daemon(int32_t saID, bool runOnCreate = true) : SystemAbility(saID, runOnCreate) {}; virtual ~Daemon() = default; void OnStart() override; @@ -46,10 +46,10 @@ public: private: Daemon(); - ServiceRunningState state_{ServiceRunningState::STATE_NOT_START}; + ServiceRunningState state_ { ServiceRunningState::STATE_NOT_START }; static sptr instance_; static std::mutex instanceLock_; - bool registerToService_{false}; + bool registerToService_ { false }; void PublishSA(); void RegisterOsAccount(); diff --git a/services/distributedfiledaemon/include/ipc/i_daemon.h b/services/distributedfiledaemon/include/ipc/i_daemon.h index fce520673c0ca6f62a03c02a65925712fd3b58e7..d67264daa9bda0f24d55dd43b3aaeb3f8481db67 100644 --- a/services/distributedfiledaemon/include/ipc/i_daemon.h +++ b/services/distributedfiledaemon/include/ipc/i_daemon.h @@ -28,7 +28,7 @@ public: }; virtual int32_t EchoServerDemo(const std::string &echoStr) = 0; - static inline const std::string SERVICE_NAME{"ohos.storage.distributedfile.daemon"}; + static inline const std::string SERVICE_NAME { "ohos.storage.distributedfile.daemon" }; DECLARE_INTERFACE_DESCRIPTOR(u"ohos.storage.distributedfile.daemon") }; } // namespace DistributedFile diff --git a/services/distributedfiledaemon/include/mountpoint/mount_point.h b/services/distributedfiledaemon/include/mountpoint/mount_point.h index 4c047f41cba4369f6e6b3fb805751b8ba566c6d2..9887e7331b0527fec91d0cfcf21fbe0416c9d758 100644 --- a/services/distributedfiledaemon/include/mountpoint/mount_point.h +++ b/services/distributedfiledaemon/include/mountpoint/mount_point.h @@ -50,7 +50,7 @@ private: void Mount() const; void Umount() const; static std::atomic idGen_; - uint32_t id_{0}; + uint32_t id_ {0}; }; } // namespace DistributedFile } // namespace Storage diff --git a/services/distributedfiledaemon/include/network/kernel_talker.h b/services/distributedfiledaemon/include/network/kernel_talker.h index d549605543863beb72144feea3d273ec9c6b5fba..036ba4ce9958c950bd5b22b968fb8b823c6cb02f 100644 --- a/services/distributedfiledaemon/include/network/kernel_talker.h +++ b/services/distributedfiledaemon/include/network/kernel_talker.h @@ -92,10 +92,10 @@ private: std::weak_ptr mountPoint_; std::mutex cmdMutex_; - std::atomic isRunning_{true}; - std::unique_ptr pollThread_{nullptr}; - std::function GetSessionCallback_{nullptr}; - std::function CloseSessionCallback_{nullptr}; + std::atomic isRunning_ {true}; + std::unique_ptr pollThread_ {nullptr}; + std::function GetSessionCallback_ {nullptr}; + std::function CloseSessionCallback_ {nullptr}; }; } // namespace DistributedFile } // namespace Storage diff --git a/services/distributedfiledaemon/include/network/softbus/softbus_agent.h b/services/distributedfiledaemon/include/network/softbus/softbus_agent.h index 28d88c4b7f4415438e1c523d786b456cf1241f8d..03c7f14ffd45a43fb7ad20d5575bd3e2205f376c 100644 --- a/services/distributedfiledaemon/include/network/softbus/softbus_agent.h +++ b/services/distributedfiledaemon/include/network/softbus/softbus_agent.h @@ -16,8 +16,8 @@ #ifndef SOFTBUS_AGENT_H #define SOFTBUS_AGENT_H -#include "network/network_agent_template.h" #include +#include "network/network_agent_template.h" namespace OHOS { namespace Storage { diff --git a/services/distributedfiledaemon/include/network/softbus/softbus_session.h b/services/distributedfiledaemon/include/network/softbus/softbus_session.h index 4816c3eaddac5d9a9cb69f65bd1705547b1867d9..4aed8576ada61d65876790e9b60ca72bdf8252fb 100644 --- a/services/distributedfiledaemon/include/network/softbus/softbus_session.h +++ b/services/distributedfiledaemon/include/network/softbus/softbus_session.h @@ -36,7 +36,7 @@ public: private: int sessionId_; std::string cid_; - int32_t socketFd_{INVALID_SOCKET_FD}; + int32_t socketFd_ {INVALID_SOCKET_FD}; std::array key_; bool IsServerSide_; }; diff --git a/services/distributedfiledaemon/src/device/device_manager_agent.cpp b/services/distributedfiledaemon/src/device/device_manager_agent.cpp index bde0253ac75fb1a4d96052622db52f476339b449..dba021dcf3417568a7b49a72617e5be3d16e68a2 100644 --- a/services/distributedfiledaemon/src/device/device_manager_agent.cpp +++ b/services/distributedfiledaemon/src/device/device_manager_agent.cpp @@ -165,9 +165,7 @@ void DeviceManagerAgent::OnDeviceOnline(const DistributedHardware::DmDeviceInfo } auto cmd = make_unique>(&NetworkAgentTemplate::ConnectDeviceAsync, info); - cmd->UpdateOption({ - .tryTimes_ = MAX_RETRY_COUNT, - }); + cmd->UpdateOption({.tryTimes_ = MAX_RETRY_COUNT}); networkAgent->Recv(move(cmd)); LOGI("OnDeviceOnline end"); diff --git a/services/distributedfiledaemon/src/network/kernel_talker.cpp b/services/distributedfiledaemon/src/network/kernel_talker.cpp index 87b7f877ff81bfce3b29b8cc67748cb93ad54888..7e64a30fb1cf116197789b34047184d743dd219f 100644 --- a/services/distributedfiledaemon/src/network/kernel_talker.cpp +++ b/services/distributedfiledaemon/src/network/kernel_talker.cpp @@ -50,7 +50,7 @@ struct OfflineParam { uint8_t remoteCid[CID_MAX_LEN]; } __attribute__((packed)); -enum { +enum CmdCode { CMD_UPDATE_SOCKET = 0, CMD_UPDATE_DEVSL, CMD_OFF_LINE, @@ -58,7 +58,7 @@ enum { CMD_CNT, }; -enum { +enum SocketStat { SOCKET_STAT_ACCEPT = 0, SOCKET_STAT_OPEN, }; diff --git a/services/distributedfiledaemon/src/network/network_agent_template.cpp b/services/distributedfiledaemon/src/network/network_agent_template.cpp index fabad4140de23ba4d74f7aec73b9dc93d5b36aaf..e5d2d9e1e4633ffd6a550004ef392db573f448e0 100644 --- a/services/distributedfiledaemon/src/network/network_agent_template.cpp +++ b/services/distributedfiledaemon/src/network/network_agent_template.cpp @@ -56,9 +56,7 @@ void NetworkAgentTemplate::ConnectOnlineDevices() for (const auto &info : infos) { auto cmd = make_unique>(&NetworkAgentTemplate::ConnectDeviceAsync, info); - cmd->UpdateOption({ - .tryTimes_ = MAX_RETRY_COUNT, - }); + cmd->UpdateOption({.tryTimes_ = MAX_RETRY_COUNT}); Recv(move(cmd)); } } @@ -83,9 +81,7 @@ void NetworkAgentTemplate::AcceptSession(shared_ptr session) { auto cmd = make_unique>>( &NetworkAgentTemplate::AcceptSessionInner, session); - cmd->UpdateOption({ - .tryTimes_ = 1, - }); + cmd->UpdateOption({.tryTimes_ = 1}); Recv(move(cmd)); } @@ -100,9 +96,7 @@ void NetworkAgentTemplate::GetSessionProcess(NotifyParam ¶m) { auto cmd = make_unique>(&NetworkAgentTemplate::GetSessionProcessInner, param); - cmd->UpdateOption({ - .tryTimes_ = 1, - }); + cmd->UpdateOption({.tryTimes_ = 1}); Recv(move(cmd)); } diff --git a/services/distributedfiledaemon/src/network/session_pool.cpp b/services/distributedfiledaemon/src/network/session_pool.cpp index 0bf259db4a61ef699b9835ac2972b496de915fce..0303a552f45bc653dc30f9577957bbe213ef8aad 100644 --- a/services/distributedfiledaemon/src/network/session_pool.cpp +++ b/services/distributedfiledaemon/src/network/session_pool.cpp @@ -59,7 +59,7 @@ void SessionPool::ReleaseAllSession() lock_guard lock(sessionPoolLock_); for (auto iter = usrSpaceSessionPool_.begin(); iter != usrSpaceSessionPool_.end();) { talker_->SinkOfflineCmdToKernel((*iter)->GetCid()); - /* device offline, session release by softbus*/ + /* device offline, session release by softbus */ iter = usrSpaceSessionPool_.erase(iter); } } diff --git a/services/distributedfiledaemon/src/network/softbus/softbus_agent.cpp b/services/distributedfiledaemon/src/network/softbus/softbus_agent.cpp index ccb14e7c3962aa6fd42db47165e02311959d11bb..8ff475ab4a2ccf8b563330049941b7605ae5b4a4 100644 --- a/services/distributedfiledaemon/src/network/softbus/softbus_agent.cpp +++ b/services/distributedfiledaemon/src/network/softbus/softbus_agent.cpp @@ -138,9 +138,7 @@ int SoftbusAgent::OnSessionOpened(const int sessionId, const int result) if (IsContinueRetry(cid)) { auto cmd = make_unique>( &NetworkAgentTemplate::ConnectDeviceAsync, info); - cmd->UpdateOption({ - .tryTimes_ = 1, - }); + cmd->UpdateOption({.tryTimes_ = 1}); Recv(move(cmd)); } else { LOGE("Exceeded the maximum number of retries, not retry"); diff --git a/services/distributedfiledaemon/test/unittest/device/device_manager_agent_test.cpp b/services/distributedfiledaemon/test/unittest/device/device_manager_agent_test.cpp index c029960ebcccff7a8bcd290e236d90cafa6c3ecc..8fda2f32eb4aef3828f346da7e3937dc59373a74 100644 --- a/services/distributedfiledaemon/test/unittest/device/device_manager_agent_test.cpp +++ b/services/distributedfiledaemon/test/unittest/device/device_manager_agent_test.cpp @@ -13,8 +13,8 @@ * limitations under the License. */ -#include "device/device_manager_agent.h" #include +#include "device/device_manager_agent.h" namespace OHOS { namespace Storage { diff --git a/test/moduletest/src/distributedfiledaemon_service_test.cpp b/test/moduletest/src/distributedfiledaemon_service_test.cpp index 38199d5d3371b73ca77a1ea287f8b8b0b9e21cdb..13d9b452132b200ca738e1713b79443a9dac40cb 100644 --- a/test/moduletest/src/distributedfiledaemon_service_test.cpp +++ b/test/moduletest/src/distributedfiledaemon_service_test.cpp @@ -675,7 +675,6 @@ HWTEST_F(DistributedFileDaemonServiceTest, distributedFileDaemon_service_test_01 strcpy_s(param.remoteCid, CID_MAX_LEN, str.data()); kt.NotifyHandler(param); } - EXPECT_EQ(0, 0); } diff --git a/utils/system/include/utils_actor.h b/utils/system/include/utils_actor.h index 18b27291d75261fe7975b53ae3153e628ae9750c..35a902a2a2f2214f73dd5344d895e63e7256f7b8 100644 --- a/utils/system/include/utils_actor.h +++ b/utils/system/include/utils_actor.h @@ -65,8 +65,8 @@ public: protected: ThreadSafeQueue> pendingCmds_; - Ctx *ctx_{nullptr}; - uint32_t retryTimes_{1}; + Ctx *ctx_ {nullptr}; + uint32_t retryTimes_ {1}; std::thread loop_; std::list> retryTasks; @@ -89,20 +89,14 @@ private: void StartCtx() { auto startCmd = std::make_unique>(&Ctx::Start); - startCmd->UpdateOption({ - .importance_ = CmdImportance::SUBVITAL, - .tryTimes_ = retryTimes_, - }); + startCmd->UpdateOption({.importance_ = CmdImportance::SUBVITAL, .tryTimes_ = retryTimes_}); pendingCmds_.Push(std::move(startCmd)); } void StopCtx() { auto cmd = std::make_unique>(&Ctx::Stop); - cmd->UpdateOption({ - .importance_ = CmdImportance::VITAL, - .tryTimes_ = 1, - }); + cmd->UpdateOption({.importance_ = CmdImportance::VITAL, .tryTimes_ = 1}); pendingCmds_.Push(std::move(cmd)); } diff --git a/utils/system/include/utils_cmd.h b/utils/system/include/utils_cmd.h index fc41bfc7e6f4aa03cab1d21facd597110c2c8cd9..f45ddd7d109450defa57a639dd57a48a4e654b65 100644 --- a/utils/system/include/utils_cmd.h +++ b/utils/system/include/utils_cmd.h @@ -37,8 +37,8 @@ enum class CmdImportance { }; struct CmdOptions { - CmdImportance importance_{CmdImportance::TRIVIAL}; - uint32_t tryTimes_{1}; + CmdImportance importance_ { CmdImportance::TRIVIAL }; + uint32_t tryTimes_ {1}; }; template diff --git a/utils/system/include/utils_dfs_thread.h b/utils/system/include/utils_dfs_thread.h index 593ec79fd7a80936e9f77087251185c763524558..4643fec67029223b437747f6e91e8a8ec0a57833 100644 --- a/utils/system/include/utils_dfs_thread.h +++ b/utils/system/include/utils_dfs_thread.h @@ -15,12 +15,12 @@ #ifndef UTILS_DFS_THREAD_H #define UTILS_DFS_THREAD_H -#include "utils_log.h" #include #include #include #include #include +#include "utils_log.h" namespace OHOS { namespace Storage { @@ -126,11 +126,11 @@ public: } private: - std::atomic_bool running_{false}; - std::mutex threadMutex_{}; - std::unique_ptr thread_{nullptr}; - std::mutex sleepMutex_{}; - std::condition_variable sleepCv_{}; + std::atomic_bool running_ {false}; + std::mutex threadMutex_ {}; + std::unique_ptr thread_ {nullptr}; + std::mutex sleepMutex_ {}; + std::condition_variable sleepCv_ {}; }; } // namespace Utils } // namespace DistributedFile diff --git a/utils/system/include/utils_exception.h b/utils/system/include/utils_exception.h index 6afd215aa2f29131fe328e6932bf2ab195d75a66..46fb45290c01d9c22bdef493114928563a1a1ecf 100644 --- a/utils/system/include/utils_exception.h +++ b/utils/system/include/utils_exception.h @@ -36,7 +36,7 @@ enum { class Exception : public std::exception { public: - Exception(int code, const std::string &msg) : code_(code), msg_(msg){}; + Exception(int code, const std::string &msg) : code_(code), msg_(msg) {}; uint32_t code() const noexcept { @@ -49,7 +49,7 @@ public: } private: - int code_{ERR_DEFAULT}; + int code_ {ERR_DEFAULT}; std::string msg_; }; diff --git a/utils/system/include/utils_singleton.h b/utils/system/include/utils_singleton.h index ffa1b58b5ea85b36a353e5cd77661c5c8673132a..3cdff6b8b8d383d20502fcf7532de2b5f29f2b7e 100644 --- a/utils/system/include/utils_singleton.h +++ b/utils/system/include/utils_singleton.h @@ -16,10 +16,10 @@ #ifndef UTILS_SINGLETON_H #define UTILS_SINGLETON_H -#include "nocopyable.h" #include #include #include +#include "nocopyable.h" namespace OHOS { namespace Storage { diff --git a/utils/system/include/utils_thread_safe_queue.h b/utils/system/include/utils_thread_safe_queue.h index fb6139dcc0845e461f5729e5b7283f3070313154..11a06347d60ca616f19e023f6ae965b04478426f 100644 --- a/utils/system/include/utils_thread_safe_queue.h +++ b/utils/system/include/utils_thread_safe_queue.h @@ -27,7 +27,6 @@ namespace OHOS { namespace Storage { namespace DistributedFile { - /** * @brief A Thread-safe Queue. * @@ -40,7 +39,6 @@ namespace DistributedFile { * @tparam T Any type. Aggregate data type is prefered * */ - template class ThreadSafeQueue { public: @@ -94,7 +92,7 @@ private: std::mutex mutex_; std::condition_variable cv_; - bool halted{false}; + bool halted {false}; }; } // namespace DistributedFile } // namespace Storage