LCOV - code coverage report
Current view: top level - src - publisher.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 17 17 100.0 %
Date: 2025-09-09 12:09:29 Functions: 1 1 100.0 %

          Line data    Source code
       1             : #include "publisher.hpp"
       2             : #include "tohost_monitor.hpp"
       3             : #include "log.hpp"
       4             : 
       5       31623 : std::uint8_t Publisher::truncate_msg_if_too_large(iovec *iov, uint32_t& size, std::uint8_t status)
       6             : {
       7             :     //IOV length
       8       31623 :     if (m_max_iov_len != 0 and size > m_max_iov_len) {
       9       13801 :         size = m_max_iov_len;
      10       13801 :         LOG_DBG("Truncating to IOV %u", m_max_iov_len);
      11       13801 :         status |= SW_TRUNC;
      12             :     }
      13             : 
      14             :     //Max message size
      15             :     size_t byte_counter = 1;  // status byte
      16      244922 :     for (uint32_t i = 0; i < size; ++i){
      17      213299 :         byte_counter += iov[i].iov_len;
      18      213299 :         if (byte_counter > m_max_msg_size){
      19       31623 :             size_t retain_iov_len = iov[i].iov_len - (byte_counter - m_max_msg_size);
      20       31623 :             if (retain_iov_len == 0){
      21        4001 :                 LOG_DBG("Truncating IOV: length was %u now is %u", size, i);
      22        4001 :                 size = i;
      23             :             } else {
      24       27622 :                 LOG_DBG("Truncating IOV and last entry: length was %u now is %u, last entry was %u bytes, now %u", size, i+1, iov[i].iov_len, retain_iov_len);
      25       27622 :                 size = i+1;
      26       27622 :                 iov[i].iov_len = retain_iov_len;                
      27             :             }
      28       31623 :             status |= SW_TRUNC;
      29             :         }
      30             :     }
      31       31623 :     return status;
      32             : }

Generated by: LCOV version 1.0