[usb_uart] Fix clang-tidy findings (#16835)

This commit is contained in:
Jonathan Swoboda
2026-06-05 12:03:22 -04:00
committed by GitHub
parent 351b986896
commit 42cf421f5c
5 changed files with 96 additions and 94 deletions
+11 -13
View File
@@ -141,13 +141,12 @@ void USBUartChannel::write_array(const uint8_t *data, size_t len) {
}
#ifdef USE_UART_DEBUGGER
if (this->debug_) {
constexpr size_t BATCH = 16;
char buf[4 + format_hex_pretty_size(BATCH)]; // ">>> " + "XX,XX,...,XX\0"
for (size_t off = 0; off < len; off += BATCH) {
size_t n = std::min(len - off, BATCH);
memcpy(buf, ">>> ", 4);
format_hex_pretty_to(buf + 4, sizeof(buf) - 4, data + off, n, ',');
ESP_LOGD(TAG, "%s%s", this->debug_prefix_.c_str(), buf);
constexpr size_t batch = 16;
char buf[format_hex_pretty_size(batch)]; // "XX,XX,...,XX\0"
for (size_t off = 0; off < len; off += batch) {
size_t n = std::min(len - off, batch);
format_hex_pretty_to(buf, data + off, n, ',');
ESP_LOGD(TAG, "%s>>> %s", this->debug_prefix_.c_str(), buf);
}
}
#endif
@@ -222,10 +221,9 @@ void USBUartComponent::loop() {
#ifdef USE_UART_DEBUGGER
if (channel->debug_) {
char buf[4 + format_hex_pretty_size(usb_host::USB_MAX_PACKET_SIZE)]; // "<<< " + hex
memcpy(buf, "<<< ", 4);
format_hex_pretty_to(buf + 4, sizeof(buf) - 4, chunk->data, chunk->length, ',');
ESP_LOGD(TAG, "%s%s", channel->debug_prefix_.c_str(), buf);
char buf[format_hex_pretty_size(usb_host::USB_MAX_PACKET_SIZE)]; // "XX,XX,...,XX\0"
format_hex_pretty_to(buf, chunk->data, chunk->length, ',');
ESP_LOGD(TAG, "%s<<< %s", channel->debug_prefix_.c_str(), buf);
}
#endif
@@ -528,10 +526,10 @@ void USBUartTypeCdcAcm::enable_channels() {
}
});
}
this->start_channels();
this->start_channels_();
}
void USBUartTypeCdcAcm::start_channels() {
void USBUartTypeCdcAcm::start_channels_() {
for (auto *channel : this->channels_) {
if (!channel->initialised_.load())
continue;