diff --git a/src/include/perfect_link.hpp b/src/include/perfect_link.hpp index 15daff0..ac38993 100644 --- a/src/include/perfect_link.hpp +++ b/src/include/perfect_link.hpp @@ -155,6 +155,7 @@ inline auto PerfectLink::_prepare_message( const auto message_size = 1 + sizeof(MessageIdType) + sizeof(ProcessIdType) + std::get<1>(metadata_value) + + sizeof(MessageSizeType) + (std::get<1>(datas) + ... + 0) + (sizeof...(Data) * sizeof(MessageSizeType)); if (message_size > MAX_MESSAGE_SIZE) { diff --git a/src/src/main.cpp b/src/src/main.cpp index 7d16677..9b202bf 100644 --- a/src/src/main.cpp +++ b/src/src/main.cpp @@ -227,12 +227,13 @@ int main(int argc, char** argv) { // pack 8 datas in one message constexpr auto pack = 8; std::array msg; - for (SendType n = pack; n <= m; n += 8) { + for (SendType n = pack; n <= m; n += pack) { logger.set_sent_amount(n); - for (size_t j = 1; j <= pack; j++) { - for (size_t i = 0; i < sizeof(SendType); i++) { - msg[(j - 1) * sizeof(SendType) + i] = - ((n - pack + j) >> (i * 8)) & 0xff; + for (SendType j = 1; j <= pack; j++) { + const SendType num = (n - pack + j); + for (SendType i = 0; i < sizeof(SendType); i++) { + std::size_t index = (j - 1) * sizeof(SendType) + i; + msg[index] = (num >> (i * 8)) & 0xff; } }