Skip to content

Commit

Permalink
Use data() instead of begin() in Protocols.cpp (#33476)
Browse files Browse the repository at this point in the history
* Use data() instead of begin() in Protocols.cpp

The GetProtocolName() function tries to store the result of
std::array<T>::begin() in a raw pointer type, but this no longer works
on some newer versions of clang, since clang now returns an iterator
object. This change fixes this by switching to std::array<T>::data()
instead, which always returns a raw pointer.

* Restyled by whitespace

---------

Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Dec 17, 2024
1 parent 58027b9 commit 1802740
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/protocols/Protocols.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,27 +86,27 @@ const char * GetMessageTypeName(Id protocolId, uint8_t msgType)
switch (protocolId.GetProtocolId())
{
case InteractionModel::Id.GetProtocolId():
lookupTable = MessageTypeTraits<InteractionModel::MsgType>::GetTypeToNameTable()->begin();
lookupTable = MessageTypeTraits<InteractionModel::MsgType>::GetTypeToNameTable()->data();
lookupTableSize = MessageTypeTraits<InteractionModel::MsgType>::GetTypeToNameTable()->size();
break;

case SecureChannel::Id.GetProtocolId():
lookupTable = MessageTypeTraits<SecureChannel::MsgType>::GetTypeToNameTable()->begin();
lookupTable = MessageTypeTraits<SecureChannel::MsgType>::GetTypeToNameTable()->data();
lookupTableSize = MessageTypeTraits<SecureChannel::MsgType>::GetTypeToNameTable()->size();
break;

case BDX::Id.GetProtocolId():
lookupTable = MessageTypeTraits<bdx::MessageType>::GetTypeToNameTable()->begin();
lookupTable = MessageTypeTraits<bdx::MessageType>::GetTypeToNameTable()->data();
lookupTableSize = MessageTypeTraits<bdx::MessageType>::GetTypeToNameTable()->size();
break;

case Echo::Id.GetProtocolId():
lookupTable = MessageTypeTraits<Echo::MsgType>::GetTypeToNameTable()->begin();
lookupTable = MessageTypeTraits<Echo::MsgType>::GetTypeToNameTable()->data();
lookupTableSize = MessageTypeTraits<Echo::MsgType>::GetTypeToNameTable()->size();
break;

case UserDirectedCommissioning::Id.GetProtocolId():
lookupTable = MessageTypeTraits<UserDirectedCommissioning::MsgType>::GetTypeToNameTable()->begin();
lookupTable = MessageTypeTraits<UserDirectedCommissioning::MsgType>::GetTypeToNameTable()->data();
lookupTableSize = MessageTypeTraits<UserDirectedCommissioning::MsgType>::GetTypeToNameTable()->size();
break;

Expand Down

0 comments on commit 1802740

Please sign in to comment.