diff options
| author | hathach <[email protected]> | 2025-05-16 16:39:53 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2025-05-16 16:39:53 +0700 |
| commit | 67389f37f2a9dabc33b9f180d49c827e9616572c (patch) | |
| tree | 652923263998d67a42e026295ee40b12217a825f /src/common | |
| parent | 531fb695312b0e1cdade446b68d7049053897405 (diff) | |
follow up to pr3118, interface also end with IAD. Add more checks
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/tusb_types.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/common/tusb_types.h b/src/common/tusb_types.h index e000a4bd3..fd7f01b67 100644 --- a/src/common/tusb_types.h +++ b/src/common/tusb_types.h @@ -586,6 +586,12 @@ TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_desc_subtype(void const* desc) { return ((uint8_t const*) desc)[DESC_OFFSET_SUBTYPE]; } +TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_desc_is_valid(void const* desc, uint8_t const* desc_end) { + const uint8_t* desc8 = (uint8_t const*) desc; + return (desc8 < desc_end) && (tu_desc_next(desc) <= desc_end); +} + + // find descriptor that match byte1 (type) uint8_t const * tu_desc_find(uint8_t const* desc, uint8_t const* end, uint8_t byte1); |
