From 5e14596cd8e3784bc5950a9ca241c23859d12964 Mon Sep 17 00:00:00 2001 From: wangcong Date: Thu, 25 Mar 2021 22:17:44 +0800 Subject: [PATCH] fix mindrt cpplint warning --- mindspore/core/mindrt/include/actor/actorapp.h | 10 ++++++++-- mindspore/core/mindrt/include/actor/msg.h | 5 ++++- mindspore/core/mindrt/include/actor/naught.h | 1 + mindspore/core/mindrt/include/async/apply.h | 2 ++ mindspore/core/mindrt/include/async/async.h | 4 ++++ mindspore/core/mindrt/include/async/result.h | 4 ++-- mindspore/core/mindrt/include/async/spinlock.h | 4 ++-- mindspore/core/mindrt/include/async/uuid_base.h | 3 ++- .../core/mindrt/include/async/uuid_generator.h | 3 ++- mindspore/core/mindrt/src/actor/actormgr.cc | 5 +++++ mindspore/core/mindrt/src/actor/actormgr.h | 6 +++++- mindspore/core/mindrt/src/actor/actorpolicy.h | 5 ++++- .../core/mindrt/src/actor/actorpolicyinterface.h | 7 +++++-- mindspore/core/mindrt/src/actor/actorthread.cc | 2 ++ mindspore/core/mindrt/src/actor/actorthread.h | 2 ++ mindspore/core/mindrt/src/actor/iomgr.h | 15 ++++++++------- 16 files changed, 58 insertions(+), 20 deletions(-) diff --git a/mindspore/core/mindrt/include/actor/actorapp.h b/mindspore/core/mindrt/include/actor/actorapp.h index 6c23b288cb..bb8b9c01c0 100644 --- a/mindspore/core/mindrt/include/actor/actorapp.h +++ b/mindspore/core/mindrt/include/actor/actorapp.h @@ -17,6 +17,11 @@ #ifndef MINDSPORE_CORE_MINDRT_INCLUDE_ACTOR_ACTORAPP_H #define MINDSPORE_CORE_MINDRT_INCLUDE_ACTOR_ACTORAPP_H +#include +#include +#include +#include + #include "actor/actor.h" namespace mindspore { @@ -33,7 +38,7 @@ class AppActor : public ActorBase { public: typedef std::function)> APPBehavior; - AppActor(const std::string &name) : ActorBase(name) {} + explicit AppActor(const std::string &name) : ActorBase(name) {} ~AppActor() {} inline int Send(const AID &to, std::unique_ptr msg) { return ActorBase::Send(to, std::move(msg)); } @@ -63,7 +68,8 @@ class AppActor : public ActorBase { template static void BehaviorBase(T *t, void (T::*method)(const AID &, std::unique_ptr), std::unique_ptr msg) { - (t->*method)(msg->From(), std::move(std::unique_ptr((M *)static_cast(msg.get())->ptr))); + (t->*method)(msg->From(), + std::move(std::unique_ptr(reinterpret_cast(static_cast(msg.get())->ptr)))); return; } diff --git a/mindspore/core/mindrt/include/actor/msg.h b/mindspore/core/mindrt/include/actor/msg.h index e4764941be..2c54aa367c 100644 --- a/mindspore/core/mindrt/include/actor/msg.h +++ b/mindspore/core/mindrt/include/actor/msg.h @@ -17,6 +17,9 @@ #ifndef MINDSPORE_CORE_MINDRT_INCLUDE_ACTOR_MSG_H #define MINDSPORE_CORE_MINDRT_INCLUDE_ACTOR_MSG_H +#include +#include + #include "actor/aid.h" namespace mindspore { @@ -33,7 +36,7 @@ class MessageBase { KTERMINATE, }; - MessageBase(Type eType = Type::KMSG) : from(), name(), type(eType) {} + explicit MessageBase(Type eType = Type::KMSG) : from(), name(), type(eType) {} explicit MessageBase(const std::string &sName, Type eType = Type::KMSG) : from(), name(sName), type(eType) {} diff --git a/mindspore/core/mindrt/include/actor/naught.h b/mindspore/core/mindrt/include/actor/naught.h index 6e321f07dd..d030a54abd 100644 --- a/mindspore/core/mindrt/include/actor/naught.h +++ b/mindspore/core/mindrt/include/actor/naught.h @@ -18,6 +18,7 @@ #define MINDSPORE_CORE_MINDRT_INCLUDE_ACTOR_NAUGHT_H #include +#include namespace mindspore { diff --git a/mindspore/core/mindrt/include/async/apply.h b/mindspore/core/mindrt/include/async/apply.h index 444374c9d6..75b8691a1a 100644 --- a/mindspore/core/mindrt/include/async/apply.h +++ b/mindspore/core/mindrt/include/async/apply.h @@ -17,6 +17,8 @@ #ifndef MINDSPORE_CORE_MINDRT_INCLUDE_ASYNC_APPLY_H #define MINDSPORE_CORE_MINDRT_INCLUDE_ASYNC_APPLY_H +#include + namespace mindspore { template diff --git a/mindspore/core/mindrt/include/async/async.h b/mindspore/core/mindrt/include/async/async.h index 99ba1f537e..8814363b57 100644 --- a/mindspore/core/mindrt/include/async/async.h +++ b/mindspore/core/mindrt/include/async/async.h @@ -17,6 +17,10 @@ #ifndef MINDSPORE_CORE_MINDRT_INCLUDE_ASYNC_ASYNC_H #define MINDSPORE_CORE_MINDRT_INCLUDE_ASYNC_ASYNC_H +#include +#include +#include + #include "actor/actor.h" #include "actor/buslog.h" diff --git a/mindspore/core/mindrt/include/async/result.h b/mindspore/core/mindrt/include/async/result.h index 6eab1d3745..f830476f57 100644 --- a/mindspore/core/mindrt/include/async/result.h +++ b/mindspore/core/mindrt/include/async/result.h @@ -19,8 +19,8 @@ #include -#include "option.h" -#include "status.h" +#include "async/option.h" +#include "async/status.h" namespace mindspore { diff --git a/mindspore/core/mindrt/include/async/spinlock.h b/mindspore/core/mindrt/include/async/spinlock.h index ad19c71212..730bef435c 100644 --- a/mindspore/core/mindrt/include/async/spinlock.h +++ b/mindspore/core/mindrt/include/async/spinlock.h @@ -24,8 +24,8 @@ namespace mindspore { class SpinLock { public: void Lock() { - while (locked.test_and_set(std::memory_order_acquire)) - ; + while (locked.test_and_set(std::memory_order_acquire)) { + } } void Unlock() { locked.clear(std::memory_order_release); } diff --git a/mindspore/core/mindrt/include/async/uuid_base.h b/mindspore/core/mindrt/include/async/uuid_base.h index 5833f041e8..c870d91edd 100644 --- a/mindspore/core/mindrt/include/async/uuid_base.h +++ b/mindspore/core/mindrt/include/async/uuid_base.h @@ -22,6 +22,7 @@ #include #include #include +#include #include "async/option.h" namespace mindspore { @@ -88,7 +89,7 @@ std::basic_ostream &operator<<(std::basic_ostream &s, const struct u int i = 0; for (const uint8_t *ptr = outputUuid.BeginAddress(); ptr < outputUuid.EndAddress(); ++ptr, ++i) { - s << std::setw(UUID_WIDTH) << (int)(*ptr); + s << std::setw(UUID_WIDTH) << static_cast(*ptr); if (i == FIRST_DELIM_OFFSET || i == SECOND_DELIM_OFFSET || i == THIRD_DELIM_OFFSET || i == FOURTH_DELIM_OFFSET) { s << '-'; } diff --git a/mindspore/core/mindrt/include/async/uuid_generator.h b/mindspore/core/mindrt/include/async/uuid_generator.h index 3827386b6a..d5a2ffd90e 100644 --- a/mindspore/core/mindrt/include/async/uuid_generator.h +++ b/mindspore/core/mindrt/include/async/uuid_generator.h @@ -17,7 +17,8 @@ #ifndef MINDSPORE_CORE_MINDRT_INCLUDE_ASYNC_UUID_GENERATOR_H #define MINDSPORE_CORE_MINDRT_INCLUDE_ASYNC_UUID_GENERATOR_H -#include "uuid_base.h" +#include +#include "async/uuid_base.h" namespace mindspore { diff --git a/mindspore/core/mindrt/src/actor/actormgr.cc b/mindspore/core/mindrt/src/actor/actormgr.cc index 16f2065e59..1be3d6c1b8 100644 --- a/mindspore/core/mindrt/src/actor/actormgr.cc +++ b/mindspore/core/mindrt/src/actor/actormgr.cc @@ -13,6 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include +#include +#include +#include +#include #include "actor/actormgr.h" #include "actor/actorpolicy.h" diff --git a/mindspore/core/mindrt/src/actor/actormgr.h b/mindspore/core/mindrt/src/actor/actormgr.h index 40d0a12742..b39524fedf 100644 --- a/mindspore/core/mindrt/src/actor/actormgr.h +++ b/mindspore/core/mindrt/src/actor/actormgr.h @@ -18,6 +18,11 @@ #define MINDSPORE_CORE_MINDRT_SRC_ACTOR_ACTORMGR_H #include +#include +#include +#include +#include + #include "actor/actorthread.h" namespace mindspore { @@ -78,7 +83,6 @@ class ActorMgr { std::string delegate; static std::shared_ptr actorMgr; static std::map > ioMgrs; - }; // end of class ActorMgr }; // end of namespace mindspore diff --git a/mindspore/core/mindrt/src/actor/actorpolicy.h b/mindspore/core/mindrt/src/actor/actorpolicy.h index 16fcccef67..ebcbef1e91 100644 --- a/mindspore/core/mindrt/src/actor/actorpolicy.h +++ b/mindspore/core/mindrt/src/actor/actorpolicy.h @@ -16,13 +16,16 @@ #ifndef MINDSPORE_CORE_MINDRT_SRC_ACTOR_ACTORPOLICY_H #define MINDSPORE_CORE_MINDRT_SRC_ACTOR_ACTORPOLICY_H +#include +#include + #include "actor/actorpolicyinterface.h" namespace mindspore { class ShardedThread : public ActorPolicy { public: - ShardedThread(const std::shared_ptr &actor); + explicit ShardedThread(const std::shared_ptr &actor); virtual ~ShardedThread(); protected: diff --git a/mindspore/core/mindrt/src/actor/actorpolicyinterface.h b/mindspore/core/mindrt/src/actor/actorpolicyinterface.h index 132ec46406..14411d02cf 100644 --- a/mindspore/core/mindrt/src/actor/actorpolicyinterface.h +++ b/mindspore/core/mindrt/src/actor/actorpolicyinterface.h @@ -17,6 +17,9 @@ #ifndef MINDSPORE_CORE_MINDRT_SRC_ACTOR_ACTORPOLICYINTERFACE_H #define MINDSPORE_CORE_MINDRT_SRC_ACTOR_ACTORPOLICYINTERFACE_H +#include +#include + namespace mindspore { class ActorPolicy { @@ -26,8 +29,8 @@ class ActorPolicy { dequeMailbox = &mailbox2; msgCount = 0; start = false; - }; - virtual ~ActorPolicy(){}; + } + virtual ~ActorPolicy() {} inline void SwapMailbox() { std::list> *temp; temp = enqueMailbox; diff --git a/mindspore/core/mindrt/src/actor/actorthread.cc b/mindspore/core/mindrt/src/actor/actorthread.cc index 9a1347d6af..fcb1479b4e 100644 --- a/mindspore/core/mindrt/src/actor/actorthread.cc +++ b/mindspore/core/mindrt/src/actor/actorthread.cc @@ -16,6 +16,8 @@ #include "actor/actorthread.h" #include +#include +#include namespace mindspore { constexpr int MAXTHREADNAMELEN = 12; diff --git a/mindspore/core/mindrt/src/actor/actorthread.h b/mindspore/core/mindrt/src/actor/actorthread.h index 2c54a2c667..556a109c49 100644 --- a/mindspore/core/mindrt/src/actor/actorthread.h +++ b/mindspore/core/mindrt/src/actor/actorthread.h @@ -20,6 +20,8 @@ #include #include #include +#include +#include #include "actor/actor.h" diff --git a/mindspore/core/mindrt/src/actor/iomgr.h b/mindspore/core/mindrt/src/actor/iomgr.h index 1d14dc6fa2..0e2643690d 100644 --- a/mindspore/core/mindrt/src/actor/iomgr.h +++ b/mindspore/core/mindrt/src/actor/iomgr.h @@ -17,6 +17,7 @@ #ifndef MINDSPORE_CORE_MINDRT_SRC_ACTOR_IOMGR_H #define MINDSPORE_CORE_MINDRT_SRC_ACTOR_IOMGR_H #include +#include #include "actor/aid.h" #include "actor/msg.h" @@ -41,18 +42,18 @@ static const int SOCKET_KEEPINTERVAL = 5; // probes without getting a reply. static const int SOCKET_KEEPCOUNT = 3; -static const std::string BUS_MAGICID = "BUS0"; +static const char BUS_MAGICID[] = "BUS0"; -static const std::string URL_PROTOCOL_IP_SEPARATOR = "://"; +static const char URL_PROTOCOL_IP_SEPARATOR[] = "://"; -static const std::string URL_IP_PORT_SEPARATOR = ":"; +static const char URL_IP_PORT_SEPARATOR[] = ":"; -static const std::string UDP_EVLOOP_THREADNAME = "HARES_LB_Udp"; +static const char UDP_EVLOOP_THREADNAME[] = "HARES_LB_Udp"; -static const std::string TCP_RECV_EVLOOP_THREADNAME = "HARES_LB_TcpR"; -static const std::string TCP_SEND_EVLOOP_THREADNAME = "HARES_LB_TcpS"; +static const char TCP_RECV_EVLOOP_THREADNAME[] = "HARES_LB_TcpR"; +static const char TCP_SEND_EVLOOP_THREADNAME[] = "HARES_LB_TcpS"; -static const std::string HTTP_CLIENT_EVLOOP_THREADNAME = "HARES_LB_Htp"; +static const char HTTP_CLIENT_EVLOOP_THREADNAME[] = "HARES_LB_Htp"; class IOMgr { public: