diff options
| author | hathach <[email protected]> | 2026-07-02 21:34:48 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2026-07-02 21:34:48 +0700 |
| commit | bb47cd8d774bf3f250e061c677baf89efa37c644 (patch) | |
| tree | 6e55c305e6376301a1dbced6537527658d830b2a | |
| parent | a6e0710b22b0f981b71bd9069956edd477f5c7a5 (diff) | |
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 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HeF2gZ1M7GWkz6Av4BpKPg
| -rw-r--r-- | src/device/usbd.c | 5 |
1 files changed, 4 insertions, 1 deletions
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]; } } |
