summaryrefslogtreecommitdiff
path: root/src/device
diff options
context:
space:
mode:
authorhathach <[email protected]>2022-06-24 19:45:49 +0700
committerhathach <[email protected]>2022-06-24 19:46:19 +0700
commit4f6e770eda9f8c605b238f35def1edaff93a8fb8 (patch)
tree65e8c12260d3b04fe01bf933886a05094a9cf81b /src/device
parent4639cac85cf959c3bfed091c02dce1345f067c7a (diff)
add more warning option, also fix -Wconversion with rp2040
-Wuninitialized, -Wunused, -Wredundant-decls
Diffstat (limited to 'src/device')
-rw-r--r--src/device/usbd.c16
-rw-r--r--src/device/usbd_control.c2
2 files changed, 11 insertions, 7 deletions
diff --git a/src/device/usbd.c b/src/device/usbd.c
index 1806281ff..fa894accc 100644
--- a/src/device/usbd.c
+++ b/src/device/usbd.c
@@ -409,6 +409,7 @@ bool tud_init (uint8_t rhport)
for (uint8_t i = 0; i < TOTAL_DRIVER_COUNT; i++)
{
usbd_class_driver_t const * driver = get_driver(i);
+ TU_ASSERT(driver);
TU_LOG2("%s init\r\n", driver->name);
driver->init();
}
@@ -426,7 +427,9 @@ static void configuration_reset(uint8_t rhport)
{
for ( uint8_t i = 0; i < TOTAL_DRIVER_COUNT; i++ )
{
- get_driver(i)->reset(rhport);
+ usbd_class_driver_t const * driver = get_driver(i);
+ TU_ASSERT(driver, );
+ driver->reset(rhport);
}
tu_varclr(&_usbd_dev);
@@ -735,7 +738,7 @@ static bool process_control_request(uint8_t rhport, tusb_control_request_t const
// Device status bit mask
// - Bit 0: Self Powered
// - Bit 1: Remote Wakeup enabled
- uint16_t status = (_usbd_dev.self_powered ? 1 : 0) | (_usbd_dev.remote_wakeup_en ? 2 : 0);
+ uint16_t status = (uint16_t) ((_usbd_dev.self_powered ? 1u : 0u) | (_usbd_dev.remote_wakeup_en ? 2u : 0u));
tud_control_xfer(rhport, p_request, &status, 2);
}
break;
@@ -867,8 +870,8 @@ static bool process_set_config(uint8_t rhport, uint8_t cfg_num)
TU_ASSERT(desc_cfg != NULL && desc_cfg->bDescriptorType == TUSB_DESC_CONFIGURATION);
// Parse configuration descriptor
- _usbd_dev.remote_wakeup_support = (desc_cfg->bmAttributes & TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP) ? 1 : 0;
- _usbd_dev.self_powered = (desc_cfg->bmAttributes & TUSB_DESC_CONFIG_ATT_SELF_POWERED ) ? 1 : 0;
+ _usbd_dev.remote_wakeup_support = (desc_cfg->bmAttributes & TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP) ? 1u : 0u;
+ _usbd_dev.self_powered = (desc_cfg->bmAttributes & TUSB_DESC_CONFIG_ATT_SELF_POWERED ) ? 1u : 0u;
// Parse interface descriptor
uint8_t const * p_desc = ((uint8_t const*) desc_cfg) + sizeof(tusb_desc_configuration_t);
@@ -895,11 +898,12 @@ static bool process_set_config(uint8_t rhport, uint8_t cfg_num)
tusb_desc_interface_t const * desc_itf = (tusb_desc_interface_t const*) p_desc;
// Find driver for this interface
- uint16_t const remaining_len = desc_end-p_desc;
+ uint16_t const remaining_len = (uint16_t) (desc_end-p_desc);
uint8_t drv_id;
for (drv_id = 0; drv_id < TOTAL_DRIVER_COUNT; drv_id++)
{
usbd_class_driver_t const *driver = get_driver(drv_id);
+ TU_ASSERT(driver);
uint16_t const drv_len = driver->open(rhport, desc_itf, remaining_len);
if ( (sizeof(tusb_desc_interface_t) <= drv_len) && (drv_len <= remaining_len) )
@@ -1101,7 +1105,7 @@ TU_ATTR_FAST_FUNC void dcd_event_handler(dcd_event_t const * event, bool in_isr)
for (uint8_t i = 0; i < TOTAL_DRIVER_COUNT; i++)
{
usbd_class_driver_t const * driver = get_driver(i);
- if (driver->sof)
+ if (driver && driver->sof)
{
driver->sof(event->rhport, event->sof.frame_count);
}
diff --git a/src/device/usbd_control.c b/src/device/usbd_control.c
index 4f4108090..94a952df7 100644
--- a/src/device/usbd_control.c
+++ b/src/device/usbd_control.c
@@ -189,7 +189,7 @@ bool usbd_control_xfer_cb (uint8_t rhport, uint8_t ep_addr, xfer_result_t result
TU_LOG_MEM(2, _usbd_ctrl_buf, xferred_bytes, 2);
}
- _ctrl_xfer.total_xferred += xferred_bytes;
+ _ctrl_xfer.total_xferred += (uint16_t) xferred_bytes;
_ctrl_xfer.buffer += xferred_bytes;
// Data Stage is complete when all request's length are transferred or