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-11-14 15:45:10 Functions: 1 1 100.0 %

          Line data    Source code
       1             : #include "publisher.hpp"
       2             : #include "tohost_monitor.hpp"
       3             : #include "log.hpp"
       4             : 
       5       30980 : std::uint8_t Publisher::truncate_msg_if_too_large(iovec *iov, uint32_t& size, std::uint8_t status)
       6             : {
       7             :     //IOV length
       8       30980 :     if (m_max_iov_len != 0 and size > m_max_iov_len) {
       9       13529 :         size = m_max_iov_len;
      10       13529 :         LOG_DBG("Truncating to IOV %u", m_max_iov_len);
      11       13529 :         status |= SW_TRUNC;
      12             :     }
      13             : 
      14             :     //Max message size
      15             :     size_t byte_counter = 1;  // status byte
      16      240075 :     for (uint32_t i = 0; i < size; ++i){
      17      209095 :         byte_counter += iov[i].iov_len;
      18      209095 :         if (byte_counter > m_max_msg_size){
      19       30980 :             size_t retain_iov_len = iov[i].iov_len - (byte_counter - m_max_msg_size);
      20       30980 :             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       26979 :                 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       26979 :                 size = i+1;
      26       26979 :                 iov[i].iov_len = retain_iov_len;                
      27             :             }
      28       30980 :             status |= SW_TRUNC;
      29             :         }
      30             :     }
      31       30980 :     return status;
      32             : }

Generated by: LCOV version 1.0