@@ -317,26 +317,24 @@ enum { BUILTIN_DRIVER_COUNT = TU_ARRAY_SIZE(_usbd_driver) };
317
317
tu_static usbd_class_driver_t const * _app_driver = NULL ;
318
318
tu_static uint8_t _app_driver_count = 0 ;
319
319
320
- #define TOTAL_DRIVER_COUNT (_app_driver_count + BUILTIN_DRIVER_COUNT)
320
+ #define TOTAL_DRIVER_COUNT ((uint8_t) ( _app_driver_count + BUILTIN_DRIVER_COUNT) )
321
321
322
322
// virtually joins built-in and application drivers together.
323
323
// Application is positioned first to allow overwriting built-in ones.
324
324
TU_ATTR_ALWAYS_INLINE static inline usbd_class_driver_t const * get_driver (uint8_t drvid ) {
325
- usbd_class_driver_t const * driver = NULL ;
326
- if ( drvid < _app_driver_count ) {
325
+ usbd_class_driver_t const * driver = NULL ;
326
+ if (drvid < _app_driver_count ) {
327
327
// Application drivers
328
328
driver = & _app_driver [drvid ];
329
- } else if ( drvid < TOTAL_DRIVER_COUNT && BUILTIN_DRIVER_COUNT > 0 ) {
329
+ } else if (drvid < TOTAL_DRIVER_COUNT && BUILTIN_DRIVER_COUNT > 0 ) {
330
330
driver = & _usbd_driver [drvid - _app_driver_count ];
331
331
}
332
332
return driver ;
333
333
}
334
334
335
-
336
335
//--------------------------------------------------------------------+
337
336
// DCD Event
338
337
//--------------------------------------------------------------------+
339
-
340
338
enum { RHPORT_INVALID = 0xFFu };
341
339
tu_static uint8_t _usbd_rhport = RHPORT_INVALID ;
342
340
@@ -488,6 +486,7 @@ bool tud_rhport_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
488
486
// Get application driver if available
489
487
if (usbd_app_driver_get_cb ) {
490
488
_app_driver = usbd_app_driver_get_cb (& _app_driver_count );
489
+ TU_ASSERT (_app_driver_count + BUILTIN_DRIVER_COUNT <= UINT8_MAX );
491
490
}
492
491
493
492
// Init class drivers
0 commit comments