diff --git a/include/log/catalog/mipi_builder.hpp b/include/log/catalog/mipi_builder.hpp index 61fb86d2..2829b8a3 100644 --- a/include/log/catalog/mipi_builder.hpp +++ b/include/log/catalog/mipi_builder.hpp @@ -67,22 +67,20 @@ template struct builder { template static auto build(string_id id, module_id m, Ts... args) { using namespace msg; - if constexpr ((0 + ... + sizeof(Ts)) <= sizeof(std::uint32_t) * 2) { + constexpr auto payload_size = + (sizeof(id) + ... + sizeof(typename P::template pack_as_t)); + if constexpr (payload_size <= sizeof(uint32_t) * 3) { constexpr auto header_size = defn::catalog_msg_t::size::value; - constexpr auto payload_size = - stdx::sized8{(sizeof(id) + ... + - sizeof(typename P::template pack_as_t))} - .in(); using storage_t = - std::array; + std::array()>; return catalog_builder{}.template build( id, m, args...); } else { constexpr auto header_size = defn::catalog_msg_t::size::value; - constexpr auto payload_size = - (sizeof(id) + ... + sizeof(typename P::template pack_as_t)); using storage_t = std::array; return catalog_builder{}.template build( diff --git a/test/log/encoder.cpp b/test/log/encoder.cpp index d5d7a26f..8fe58bb0 100644 --- a/test/log/encoder.cpp +++ b/test/log/encoder.cpp @@ -259,6 +259,17 @@ TEST_CASE("log more than two arguments", "[mipi]") { } } +TEST_CASE("log more than two arguments whose size fits in two uint32_ts", + "[mipi]") { + CIB_LOG_ENV(logging::get_level, logging::level::TRACE); + test_critical_section::count = 0; + auto cfg = logging::binary::config{ + test_log_buf_destination{}}; + cfg.logger.log_msg(stdx::ct_format<"{} {} {}">('a', 'b', 'c')); + CHECK(test_critical_section::count == 2); +} + TEST_CASE("log to multiple destinations", "[mipi]") { CIB_LOG_ENV(logging::get_level, logging::level::TRACE); test_critical_section::count = 0;