diff --git a/code/espurna/rfbridge.cpp b/code/espurna/rfbridge.cpp index 64a4aab0..01c81ca5 100644 --- a/code/espurna/rfbridge.cpp +++ b/code/espurna/rfbridge.cpp @@ -276,12 +276,10 @@ struct RfbMessage { RfbMessage(const RfbMessage&) = default; RfbMessage(RfbMessage&&) = default; - template - explicit RfbMessage(uint8_t (&data)[Size], unsigned char repeats_) : + explicit RfbMessage(uint8_t (&data)[RfbParser::PayloadSizeBasic], unsigned char repeats_) : repeats(repeats_) { - static_assert(Size == RfbParser::PayloadSizeBasic, ""); - std::copy(data, data + Size, code); + std::copy(data, data + sizeof(data), code); } uint8_t code[RfbParser::PayloadSizeBasic] { 0u }; @@ -747,8 +745,7 @@ void _rfbSendImpl(const RfbMessage& message) { // since it's original intent was to be used with 16bit ints // TODO: both 'protocol' and 'bitlength' fit in a byte, despite being declared as 'unsigned int' -template -size_t _rfbModemPack(uint8_t(&out)[Size], RfbMessage::code_type code, unsigned int protocol, unsigned int timing, unsigned int bits) { +size_t _rfbModemPack(uint8_t (&out)[RfbMessage::BufferSize], RfbMessage::code_type code, unsigned int protocol, unsigned int timing, unsigned int bits) { static_assert((sizeof(decltype(code)) == 4) || (sizeof(decltype(code)) == 8), ""); size_t index = 0; @@ -759,7 +756,7 @@ size_t _rfbModemPack(uint8_t(&out)[Size], RfbMessage::code_type code, unsigned i out[index++] = static_cast(bits); auto bytes = _rfb_bits_for_bytes(bits); - if (bytes > (Size - index)) { + if (bytes > (sizeof(out) - index)) { return 0; }