summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorsakumisu <[email protected]>2025-05-06 22:34:41 +0800
committersakumisu <[email protected]>2025-05-06 22:34:41 +0800
commitd4dfb03afcc4622fb1e00c6df4aa9d9314b2c7ce (patch)
treebd07c748611765ad08ffd9e740a65be312f9b058 /core
parenta41000a0002d66b9ee741a2d32862941f0aa77a2 (diff)
update: add USB_ASSERT_MSG for common case
Signed-off-by: sakumisu <[email protected]>
Diffstat (limited to 'core')
-rw-r--r--core/usbh_core.c22
1 files changed, 7 insertions, 15 deletions
diff --git a/core/usbh_core.c b/core/usbh_core.c
index 03ed3b9d..406a5c3e 100644
--- a/core/usbh_core.c
+++ b/core/usbh_core.c
@@ -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);