From 6912f23618d629a4d0d9ec5626df5fc79b329c80 Mon Sep 17 00:00:00 2001 From: aineoae86-sys Date: Sun, 5 Jul 2026 15:38:17 +0800 Subject: [PATCH 1/3] Fix usbd empty builtin driver warning Generated-by: OpenAI Codex Signed-off-by: aineoae86-sys --- src/device/usbd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/device/usbd.c b/src/device/usbd.c index 70141a5bb..fc658f1c1 100644 --- a/src/device/usbd.c +++ b/src/device/usbd.c @@ -378,7 +378,7 @@ TU_ATTR_ALWAYS_INLINE static inline usbd_class_driver_t const * get_driver(uint8 driver = &_app_driver[drvid]; } else{ drvid -= _app_driver_count; - if (drvid < BUILTIN_DRIVER_COUNT) { + if (BUILTIN_DRIVER_COUNT > 0 && drvid < BUILTIN_DRIVER_COUNT) { driver = &_usbd_driver[drvid]; } } From 19274b95a6755116114d20abcbce498695a1d0c5 Mon Sep 17 00:00:00 2001 From: HiFiPhile Date: Sun, 5 Jul 2026 15:25:34 +0200 Subject: [PATCH 2/3] Fix usbd empty builtin driver warning v2 Signed-off-by: HiFiPhile --- src/device/usbd.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/device/usbd.c b/src/device/usbd.c index fc658f1c1..7a6e13f8d 100644 --- a/src/device/usbd.c +++ b/src/device/usbd.c @@ -361,13 +361,12 @@ static const usbd_class_driver_t _usbd_driver[] = { #endif }; -enum { BUILTIN_DRIVER_COUNT = TU_ARRAY_SIZE(_usbd_driver) }; - // Additional class drivers implemented by application -static const usbd_class_driver_t *_app_driver = NULL; -static uint8_t _app_driver_count = 0; +static const usbd_class_driver_t *_app_driver = NULL; +static const uint8_t _builtin_driver_count = TU_ARRAY_SIZE(_usbd_driver); +static uint8_t _app_driver_count = 0; -#define TOTAL_DRIVER_COUNT ((uint8_t) (_app_driver_count + BUILTIN_DRIVER_COUNT)) +#define TOTAL_DRIVER_COUNT ((uint8_t) (_app_driver_count + _builtin_driver_count)) // virtually joins built-in and application drivers together. // Application is positioned first to allow overwriting built-in ones. @@ -378,7 +377,7 @@ TU_ATTR_ALWAYS_INLINE static inline usbd_class_driver_t const * get_driver(uint8 driver = &_app_driver[drvid]; } else{ drvid -= _app_driver_count; - if (BUILTIN_DRIVER_COUNT > 0 && drvid < BUILTIN_DRIVER_COUNT) { + if (_builtin_driver_count > 0 && drvid < _builtin_driver_count) { driver = &_usbd_driver[drvid]; } } @@ -563,7 +562,7 @@ bool tud_rhport_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) { // Get application driver if available _app_driver = usbd_app_driver_get_cb(&_app_driver_count); - TU_ASSERT(_app_driver_count + BUILTIN_DRIVER_COUNT <= UINT8_MAX); + TU_ASSERT(_app_driver_count + _builtin_driver_count <= UINT8_MAX); // Init class drivers for (uint8_t i = 0; i < TOTAL_DRIVER_COUNT; i++) { From 073657a04e727203d0363dfb0be195b4b9bcb451 Mon Sep 17 00:00:00 2001 From: HiFiPhile Date: Sun, 5 Jul 2026 15:27:30 +0200 Subject: [PATCH 3/3] Fix usbh empty builtin driver warning Signed-off-by: HiFiPhile --- src/host/usbh.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/host/usbh.c b/src/host/usbh.c index 2709856bb..e307bb5e5 100644 --- a/src/host/usbh.c +++ b/src/host/usbh.c @@ -319,13 +319,12 @@ static usbh_class_driver_t const usbh_class_drivers[] = { #endif }; -enum { BUILTIN_DRIVER_COUNT = TU_ARRAY_SIZE(usbh_class_drivers) }; - // Additional class drivers implemented by application static usbh_class_driver_t const * _app_driver = NULL; -static uint8_t _app_driver_count = 0; +static const uint8_t _builtin_driver_count = TU_ARRAY_SIZE(usbh_class_drivers); +static uint8_t _app_driver_count = 0; -#define TOTAL_DRIVER_COUNT (_app_driver_count + BUILTIN_DRIVER_COUNT) +#define TOTAL_DRIVER_COUNT (_app_driver_count + _builtin_driver_count) // virtually joins built-in and application drivers together. // Application is positioned first to allow overwriting built-in ones. @@ -335,7 +334,7 @@ TU_ATTR_ALWAYS_INLINE static inline usbh_class_driver_t const *get_driver(uint8_ driver = &_app_driver[drv_id]; } else { drv_id -= _app_driver_count; - if (drv_id < BUILTIN_DRIVER_COUNT) { + if (_builtin_driver_count > 0 && drv_id < _builtin_driver_count) { driver = &usbh_class_drivers[drv_id]; } } @@ -547,6 +546,7 @@ bool tuh_rhport_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) { // Get application driver if available _app_driver = usbh_app_driver_get_cb(&_app_driver_count); + TU_ASSERT(_app_driver_count + _builtin_driver_count <= UINT8_MAX); // Device tu_memclr(_usbh_devices, sizeof(_usbh_devices));