From 80c84d6665a47513c406b5181b7b76304b10307c Mon Sep 17 00:00:00 2001 From: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com> Date: Fri, 5 Jun 2026 11:55:39 -0400 Subject: [PATCH] [usb_host][usb_cdc_acm][tinyusb] Fix clang-tidy findings (#16836) --- esphome/components/tinyusb/tinyusb_component.cpp | 2 +- esphome/components/tinyusb/tinyusb_component.h | 2 +- esphome/components/usb_cdc_acm/usb_cdc_acm_esp32.cpp | 6 +++--- esphome/components/usb_host/usb_host.h | 2 +- esphome/components/usb_host/usb_host_client.cpp | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/esphome/components/tinyusb/tinyusb_component.cpp b/esphome/components/tinyusb/tinyusb_component.cpp index 3cefc0454a..567a84f8c3 100644 --- a/esphome/components/tinyusb/tinyusb_component.cpp +++ b/esphome/components/tinyusb/tinyusb_component.cpp @@ -6,7 +6,7 @@ namespace esphome::tinyusb { -static const char *TAG = "tinyusb"; +static const char *const TAG = "tinyusb"; void TinyUSB::setup() { // Use the device's MAC address as its serial number if no serial number is defined diff --git a/esphome/components/tinyusb/tinyusb_component.h b/esphome/components/tinyusb/tinyusb_component.h index 7d8caade74..56c33a708f 100644 --- a/esphome/components/tinyusb/tinyusb_component.h +++ b/esphome/components/tinyusb/tinyusb_component.h @@ -17,7 +17,7 @@ enum USBDStringDescriptor : uint8_t { SIZE = 6, }; -static const char *DEFAULT_USB_STR = "ESPHome"; +static const char *const DEFAULT_USB_STR = "ESPHome"; class TinyUSB : public Component { public: diff --git a/esphome/components/usb_cdc_acm/usb_cdc_acm_esp32.cpp b/esphome/components/usb_cdc_acm/usb_cdc_acm_esp32.cpp index 5498c38515..592207efa8 100644 --- a/esphome/components/usb_cdc_acm/usb_cdc_acm_esp32.cpp +++ b/esphome/components/usb_cdc_acm/usb_cdc_acm_esp32.cpp @@ -96,9 +96,9 @@ static void tinyusb_cdc_line_coding_changed_callback(int itf, cdcacm_event_t *ev } static esp_err_t ringbuf_read_bytes(RingbufHandle_t ring_buf, uint8_t *out_buf, size_t out_buf_sz, size_t *rx_data_size, - TickType_t xTicksToWait) { + TickType_t x_ticks_to_wait) { size_t read_sz; - uint8_t *buf = static_cast(xRingbufferReceiveUpTo(ring_buf, &read_sz, xTicksToWait, out_buf_sz)); + uint8_t *buf = static_cast(xRingbufferReceiveUpTo(ring_buf, &read_sz, x_ticks_to_wait, out_buf_sz)); if (buf == nullptr) { return ESP_FAIL; @@ -186,7 +186,7 @@ void USBCDCACMInstance::usb_tx_task() { uint8_t data[CONFIG_TINYUSB_CDC_TX_BUFSIZE] = {0}; size_t tx_data_size = 0; - while (1) { + while (true) { // Wait for a notification from the bridge component ulTaskNotifyTake(pdTRUE, portMAX_DELAY); diff --git a/esphome/components/usb_host/usb_host.h b/esphome/components/usb_host/usb_host.h index 480fd86750..a9f07a5422 100644 --- a/esphome/components/usb_host/usb_host.h +++ b/esphome/components/usb_host/usb_host.h @@ -167,7 +167,7 @@ class USBClient : public Component { // USB task management static void usb_task_fn(void *arg); - [[noreturn]] void usb_task_loop() const; + [[noreturn]] void usb_task_loop_() const; // Members ordered to minimize struct padding on 32-bit platforms TransferRequest requests_[MAX_REQUESTS]{}; diff --git a/esphome/components/usb_host/usb_host_client.cpp b/esphome/components/usb_host/usb_host_client.cpp index 4ee8e2ac5e..45e2be17c7 100644 --- a/esphome/components/usb_host/usb_host_client.cpp +++ b/esphome/components/usb_host/usb_host_client.cpp @@ -236,9 +236,9 @@ void USBClient::setup() { void USBClient::usb_task_fn(void *arg) { auto *client = static_cast(arg); - client->usb_task_loop(); + client->usb_task_loop_(); } -void USBClient::usb_task_loop() const { +void USBClient::usb_task_loop_() const { while (true) { usb_host_client_handle_events(this->handle_, portMAX_DELAY); }