From a344fb5969d987f8c7e09d807ede098dd75ad32d Mon Sep 17 00:00:00 2001 From: Yakun Xu Date: Sun, 21 Jun 2020 09:11:12 +0800 Subject: [PATCH] [style] remove c++11 check and OT_NCP_CONST (#5132) --- src/ncp/ncp_base_dispatcher.cpp | 42 ++++++++++++++++----------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/src/ncp/ncp_base_dispatcher.cpp b/src/ncp/ncp_base_dispatcher.cpp index 47fa7bed6..640bd247e 100644 --- a/src/ncp/ncp_base_dispatcher.cpp +++ b/src/ncp/ncp_base_dispatcher.cpp @@ -35,7 +35,6 @@ namespace ot { namespace Ncp { -#if __cplusplus >= 201103L constexpr bool NcpBase::AreHandlerEntriesSorted(const HandlerEntry *aHandlerEntries, size_t aSize) { return aSize < 2 ? true @@ -43,16 +42,14 @@ constexpr bool NcpBase::AreHandlerEntriesSorted(const HandlerEntry *aHandlerEntr AreHandlerEntriesSorted(aHandlerEntries, aSize - 1)); } -#define OT_NCP_CONST constexpr -#else -#define OT_NCP_CONST const -#endif - NcpBase::PropertyHandler NcpBase::FindGetPropertyHandler(spinel_prop_key_t aKey) { -#define OT_NCP_GET_HANDLER_ENTRY(aPropertyName) {aPropertyName, &NcpBase::HandlePropertyGet} +#define OT_NCP_GET_HANDLER_ENTRY(aPropertyName) \ + { \ + aPropertyName, &NcpBase::HandlePropertyGet \ + } - OT_NCP_CONST static HandlerEntry sHandlerEntries[] = { + constexpr static HandlerEntry sHandlerEntries[] = { OT_NCP_GET_HANDLER_ENTRY(SPINEL_PROP_LAST_STATUS), OT_NCP_GET_HANDLER_ENTRY(SPINEL_PROP_PROTOCOL_VERSION), OT_NCP_GET_HANDLER_ENTRY(SPINEL_PROP_NCP_VERSION), @@ -330,19 +327,20 @@ NcpBase::PropertyHandler NcpBase::FindGetPropertyHandler(spinel_prop_key_t aKey) #undef OT_NCP_GET_HANDLER_ENTRY -#if __cplusplus >= 201103L static_assert(AreHandlerEntriesSorted(sHandlerEntries, OT_ARRAY_LENGTH(sHandlerEntries)), "NCP property getter entries not sorted!"); -#endif return FindPropertyHandler(sHandlerEntries, OT_ARRAY_LENGTH(sHandlerEntries), aKey); } NcpBase::PropertyHandler NcpBase::FindSetPropertyHandler(spinel_prop_key_t aKey) { -#define OT_NCP_SET_HANDLER_ENTRY(aPropertyName) {aPropertyName, &NcpBase::HandlePropertySet} +#define OT_NCP_SET_HANDLER_ENTRY(aPropertyName) \ + { \ + aPropertyName, &NcpBase::HandlePropertySet \ + } - OT_NCP_CONST static HandlerEntry sHandlerEntries[] = { + constexpr static HandlerEntry sHandlerEntries[] = { OT_NCP_SET_HANDLER_ENTRY(SPINEL_PROP_POWER_STATE), #if OPENTHREAD_CONFIG_NCP_ENABLE_MCU_POWER_STATE_CONTROL OT_NCP_SET_HANDLER_ENTRY(SPINEL_PROP_MCU_POWER_STATE), @@ -532,19 +530,20 @@ NcpBase::PropertyHandler NcpBase::FindSetPropertyHandler(spinel_prop_key_t aKey) #undef OT_NCP_SET_HANDLER_ENTRY -#if __cplusplus >= 201103L static_assert(AreHandlerEntriesSorted(sHandlerEntries, OT_ARRAY_LENGTH(sHandlerEntries)), "NCP property setter entries not sorted!"); -#endif return FindPropertyHandler(sHandlerEntries, OT_ARRAY_LENGTH(sHandlerEntries), aKey); } NcpBase::PropertyHandler NcpBase::FindInsertPropertyHandler(spinel_prop_key_t aKey) { -#define OT_NCP_INSERT_HANDLER_ENTRY(aPropertyName) {aPropertyName, &NcpBase::HandlePropertyInsert} +#define OT_NCP_INSERT_HANDLER_ENTRY(aPropertyName) \ + { \ + aPropertyName, &NcpBase::HandlePropertyInsert \ + } - OT_NCP_CONST static HandlerEntry sHandlerEntries[] = { + constexpr static HandlerEntry sHandlerEntries[] = { #if OPENTHREAD_MTD || OPENTHREAD_FTD #if OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE OT_NCP_INSERT_HANDLER_ENTRY(SPINEL_PROP_THREAD_ON_MESH_NETS), @@ -579,19 +578,20 @@ NcpBase::PropertyHandler NcpBase::FindInsertPropertyHandler(spinel_prop_key_t aK #undef OT_NCP_INSERT_HANDLER_ENTRY -#if __cplusplus >= 201103L static_assert(AreHandlerEntriesSorted(sHandlerEntries, OT_ARRAY_LENGTH(sHandlerEntries)), "NCP property setter entries not sorted!"); -#endif return FindPropertyHandler(sHandlerEntries, OT_ARRAY_LENGTH(sHandlerEntries), aKey); } NcpBase::PropertyHandler NcpBase::FindRemovePropertyHandler(spinel_prop_key_t aKey) { -#define OT_NCP_REMOVE_HANDLER_ENTRY(aPropertyName) {aPropertyName, &NcpBase::HandlePropertyRemove} +#define OT_NCP_REMOVE_HANDLER_ENTRY(aPropertyName) \ + { \ + aPropertyName, &NcpBase::HandlePropertyRemove \ + } - OT_NCP_CONST static HandlerEntry sHandlerEntries[] = { + constexpr static HandlerEntry sHandlerEntries[] = { #if OPENTHREAD_MTD || OPENTHREAD_FTD #if OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE OT_NCP_REMOVE_HANDLER_ENTRY(SPINEL_PROP_THREAD_ON_MESH_NETS), @@ -626,10 +626,8 @@ NcpBase::PropertyHandler NcpBase::FindRemovePropertyHandler(spinel_prop_key_t aK #undef OT_NCP_REMOVE_HANDLER_ENTRY -#if __cplusplus >= 201103L static_assert(AreHandlerEntriesSorted(sHandlerEntries, OT_ARRAY_LENGTH(sHandlerEntries)), "NCP property setter entries not sorted!"); -#endif return FindPropertyHandler(sHandlerEntries, OT_ARRAY_LENGTH(sHandlerEntries), aKey); }