From bb47cd8d774bf3f250e061c677baf89efa37c644 Mon Sep 17 00:00:00 2001 From: hathach Date: Thu, 2 Jul 2026 21:34:48 +0700 Subject: usbd: fix -Wtype-limits error in builds with no built-in class driver An application-class-driver-only build (all CFG_TUD_* classes 0, drivers via usbd_app_driver_get_cb) leaves _usbd_driver[] empty, so get_driver's comparison against BUILTIN_DRIVER_COUNT==0 is always false and -Werror builds fail. Compare via a local instead. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01HeF2gZ1M7GWkz6Av4BpKPg --- src/device/usbd.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/device/usbd.c b/src/device/usbd.c index ea552798d..28878a51c 100644 --- a/src/device/usbd.c +++ b/src/device/usbd.c @@ -397,7 +397,10 @@ 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) { + // via local: BUILTIN_DRIVER_COUNT is 0 when all built-in classes are disabled + // (app-driver-only build) and a direct comparison trips -Wtype-limits + uint8_t const builtin_count = BUILTIN_DRIVER_COUNT; + if (drvid < builtin_count) { driver = &_usbd_driver[drvid]; } } -- cgit v1.3.1