lib,rlc: changed return of string helper functions from char* to std::string to avoid UB

master
Pedro Alvarez 3 years ago
parent b46c5423f0
commit b53da22eb1

@ -62,8 +62,8 @@ bool rlc_am_is_unaligned(const uint8_t fi);
bool rlc_am_not_start_aligned(const uint8_t fi);
std::string
rlc_am_undelivered_sdu_info_to_string(const std::map<uint32_t, pdcp_pdu_info<rlc_amd_pdu_header_t> >& info_queue);
const char* rlc_amd_pdu_header_to_string(const rlc_amd_pdu_header_t& header);
const char* rlc_am_status_pdu_to_string(rlc_status_pdu_t* status);
std::string rlc_amd_pdu_header_to_string(const rlc_amd_pdu_header_t& header);
std::string rlc_am_status_pdu_to_string(rlc_status_pdu_t* status);
} // namespace srsran
#endif // SRSRAN_RLC_AM_LTE_PACKING_H

@ -420,7 +420,7 @@ bool rlc_am_lte_tx::poll_required()
/* According to 5.2.2.1 in 36.322 v13.3.0 a poll should be requested if
* the entire AM window is unacknowledged, i.e. no new PDU can be transmitted.
* However, it seems more appropiate to request more often if polling
* However, it seems more appropriate to request more often if polling
* is disabled otherwise, e.g. every N PDUs.
*/
if (cfg.poll_pdu == 0 && cfg.poll_byte == 0 && vt_s % rlc_am::poll_periodicity == 0) {

@ -312,7 +312,7 @@ bool rlc_am_not_start_aligned(const uint8_t fi)
/**
* Logging helpers
*/
const char* rlc_amd_pdu_header_to_string(const rlc_amd_pdu_header_t& header)
std::string rlc_amd_pdu_header_to_string(const rlc_amd_pdu_header_t& header)
{
fmt::memory_buffer buffer;
fmt::format_to(buffer,
@ -334,10 +334,10 @@ const char* rlc_amd_pdu_header_to_string(const rlc_amd_pdu_header_t& header)
}
fmt::format_to(buffer, "]");
return to_c_str(buffer);
return fmt::to_string(buffer);
}
const char* rlc_am_status_pdu_to_string(rlc_status_pdu_t* status)
std::string rlc_am_status_pdu_to_string(rlc_status_pdu_t* status)
{
fmt::memory_buffer buffer;
fmt::format_to(buffer, "ACK_SN = {}, N_nack = {}", status->ack_sn, status->N_nack);
@ -352,7 +352,7 @@ const char* rlc_am_status_pdu_to_string(rlc_status_pdu_t* status)
}
}
}
return to_c_str(buffer);
return fmt::to_string(buffer);
}
} // namespace srsran

Loading…
Cancel
Save