util: avoid calling snprintf in PrintStringsToBuffer

As we print only one character
pull/6469/head
Philippe Antoine 4 years ago committed by Victor Julien
parent 53ef65d390
commit b34c025b52

@ -229,12 +229,13 @@ void PrintStringsToBuffer(uint8_t *dst_buf, uint32_t *dst_buf_offset_ptr, uint32
const uint8_t *src_buf, const uint32_t src_buf_len)
{
uint32_t ch = 0;
for (ch = 0; ch < src_buf_len; ch++) {
PrintBufferData((char *)dst_buf, dst_buf_offset_ptr, dst_buf_size,
"%c",
(isprint((uint8_t)src_buf[ch]) ||
src_buf[ch] == '\n' ||
src_buf[ch] == '\r') ? (uint8_t)src_buf[ch] : '.');
for (ch = 0; ch < src_buf_len && *dst_buf_offset_ptr < dst_buf_size;
ch++, (*dst_buf_offset_ptr)++) {
if (isprint((uint8_t)src_buf[ch]) || src_buf[ch] == '\n' || src_buf[ch] == '\r') {
dst_buf[*dst_buf_offset_ptr] = src_buf[ch];
} else {
dst_buf[*dst_buf_offset_ptr] = '.';
}
}
dst_buf[dst_buf_size - 1] = 0;

Loading…
Cancel
Save