Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use data() instead of begin() in Protocols.cpp #33476

Merged
merged 2 commits into from
May 15, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
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.
  • Loading branch information
mwswartwout committed May 15, 2024
commit 3a7c0674b1d41a7fbb1e45969a67d83514b44da3
11 changes: 6 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 All @@ -123,3 +123,4 @@ const char * GetMessageTypeName(Id protocolId, uint8_t msgType)

} // namespace Protocols
} // namespace chip

Loading