update: add USB_ASSERT_MSG for common case

Signed-off-by: sakumisu <1203593632@qq.com>
This commit is contained in:
sakumisu
2025-05-06 22:34:41 +08:00
parent a41000a000
commit d4dfb03afc
6 changed files with 34 additions and 114 deletions

View File

@@ -227,21 +227,13 @@ static int parse_config_descriptor(struct usbh_hubport *hport, struct usb_config
cur_alt_setting = intf_desc->bAlternateSetting;
cur_ep_num = intf_desc->bNumEndpoints;
cur_ep = 0;
if (cur_iface > (CONFIG_USBHOST_MAX_INTERFACES - 1)) {
USB_LOG_ERR("Interface num overflow\r\n");
while (1) {
}
}
if (cur_alt_setting > (CONFIG_USBHOST_MAX_INTF_ALTSETTINGS - 1)) {
USB_LOG_ERR("Interface altsetting num overflow\r\n");
while (1) {
}
}
if (cur_ep_num > CONFIG_USBHOST_MAX_ENDPOINTS) {
USB_LOG_ERR("Endpoint num overflow\r\n");
while (1) {
}
}
USB_ASSERT_MSG(cur_iface < CONFIG_USBHOST_MAX_INTERFACES,
"Interface num %d overflow", cur_iface);
USB_ASSERT_MSG(cur_alt_setting < CONFIG_USBHOST_MAX_INTF_ALTSETTINGS,
"Interface altsetting num %d overflow", cur_alt_setting);
USB_ASSERT_MSG(cur_ep_num <= CONFIG_USBHOST_MAX_ENDPOINTS,
"Endpoint num %d overflow", cur_ep_num);
#if 0
USB_LOG_DBG("Interface Descriptor:\r\n");
USB_LOG_DBG("bLength: 0x%02x \r\n", intf_desc->bLength);