Skip to content

Commit

Permalink
Remove casts now that our enums are the right size. (#7841)
Browse files Browse the repository at this point in the history
#7746 made the
enums be sized correctly.

Fixes #7622
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Jul 21, 2021
1 parent a186a5b commit 5969961
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,9 @@ EmberAfKeypadInputStatus KeypadInputManager::proxyKeypadInputRequest(EmberAfKeyp

static void sendResponse(const char * responseName, EmberAfKeypadInputStatus keypadInputStatus)
{
// TODO: Once our enums are sized properly, or once we stop depending on the
// value being a certain type, we can remove the static_cast. For now the
// cast is safe because all EmberAfKeypadInputStatus values fit in uint32_t.
static_assert(std::is_same<std::underlying_type_t<EmberAfKeypadInputStatus>, uint8_t>::value, "Wrong enum size");
emberAfFillExternalBuffer((ZCL_CLUSTER_SPECIFIC_COMMAND | ZCL_FRAME_CONTROL_SERVER_TO_CLIENT), ZCL_KEYPAD_INPUT_CLUSTER_ID,
ZCL_SEND_KEY_RESPONSE_COMMAND_ID, "u", static_cast<uint8_t>(keypadInputStatus));
ZCL_SEND_KEY_RESPONSE_COMMAND_ID, "u", keypadInputStatus);

EmberStatus status = emberAfSendResponse();
if (status != EMBER_SUCCESS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,9 @@ void MediaPlaybackManager::storeNewPlaybackState(chip::EndpointId endpoint, uint

static void sendResponse(const char * responseName, chip::CommandId commandId, EmberAfMediaPlaybackStatus mediaPlaybackStatus)
{
// TODO: Once our enums are sized properly, or once we stop depending on the
// value being a certain type, we can remove the static_cast. For now the
// cast is safe because all EmberAfKeypadInputStatus values fit in uint32_t.
static_assert(std::is_same<std::underlying_type_t<EmberAfMediaPlaybackStatus>, uint8_t>::value, "Wrong enum size");
emberAfFillExternalBuffer((ZCL_CLUSTER_SPECIFIC_COMMAND | ZCL_FRAME_CONTROL_SERVER_TO_CLIENT), ZCL_MEDIA_PLAYBACK_CLUSTER_ID,
commandId, "u", static_cast<uint8_t>(mediaPlaybackStatus));
commandId, "u", mediaPlaybackStatus);

EmberStatus status = emberAfSendResponse();
if (status != EMBER_SUCCESS)
Expand Down

0 comments on commit 5969961

Please sign in to comment.