Skip to content

Commit 5755afa

Browse files
committed
Fix some IAR warnings
Signed-off-by: HiFiPhile <[email protected]>
1 parent d3ab48b commit 5755afa

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed

src/class/hid/hid_host.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,8 @@ bool hidh_open(uint8_t rhport, uint8_t daddr, tusb_desc_interface_t const* desc_
519519

520520
// Assume bNumDescriptors = 1
521521
p_hid->report_desc_type = desc_hid->bReportType;
522-
p_hid->report_desc_len = tu_unaligned_read16(&desc_hid->wReportLength);
522+
// Use offsetof to avoid pointer to the odd/misaligned address
523+
p_hid->report_desc_len = tu_unaligned_read16((uint8_t const*)desc_hid + offsetof(tusb_hid_descriptor_hid_t, wReportLength));
523524

524525
// Per HID Specs: default is Report protocol, though we will force Boot protocol when set_config
525526
p_hid->protocol_mode = _hidh_default_protocol;

src/host/usbh.c

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ bool tuh_descriptor_get_device_local(uint8_t daddr, tusb_desc_device_t* desc_dev
400400
tusb_speed_t tuh_speed_get(uint8_t daddr) {
401401
tuh_bus_info_t bus_info;
402402
tuh_bus_info_get(daddr, &bus_info);
403-
return bus_info.speed;
403+
return (tusb_speed_t)bus_info.speed;
404404
}
405405

406406
bool tuh_rhport_is_active(uint8_t rhport) {
@@ -651,7 +651,7 @@ void tuh_task_ext(uint32_t timeout_ms, bool in_isr) {
651651
tuh_xfer_t xfer = {
652652
.daddr = event.dev_addr,
653653
.ep_addr = ep_addr,
654-
.result = event.xfer_complete.result,
654+
.result = (xfer_result_t)event.xfer_complete.result,
655655
.actual_len = event.xfer_complete.len,
656656
.buflen = 0, // not available
657657
.buffer = NULL, // not available
@@ -832,18 +832,19 @@ static bool usbh_control_xfer_cb (uint8_t daddr, uint8_t ep_addr, xfer_result_t
832832
}
833833
TU_ATTR_FALLTHROUGH;
834834

835-
case CONTROL_STAGE_DATA:
836-
if (request->wLength) {
837-
TU_LOG_USBH("[%u:%u] Control data:\r\n", rhport, daddr);
838-
TU_LOG_MEM_USBH(ctrl_info->buffer, xferred_bytes, 2);
839-
}
840-
ctrl_info->actual_len = (uint16_t) xferred_bytes;
841-
842-
// ACK stage: toggle is always 1
843-
_control_set_xfer_stage(CONTROL_STAGE_ACK);
844-
const uint8_t ep_status = tu_edpt_addr(0, 1 - request->bmRequestType_bit.direction);
845-
TU_ASSERT(hcd_edpt_xfer(rhport, daddr, ep_status, NULL, 0));
846-
break;
835+
case CONTROL_STAGE_DATA: {
836+
if (request->wLength) {
837+
TU_LOG_USBH("[%u:%u] Control data:\r\n", rhport, daddr);
838+
TU_LOG_MEM_USBH(ctrl_info->buffer, xferred_bytes, 2);
839+
}
840+
ctrl_info->actual_len = (uint16_t) xferred_bytes;
841+
842+
// ACK stage: toggle is always 1
843+
_control_set_xfer_stage(CONTROL_STAGE_ACK);
844+
const uint8_t ep_status = tu_edpt_addr(0, 1 - request->bmRequestType_bit.direction);
845+
TU_ASSERT(hcd_edpt_xfer(rhport, daddr, ep_status, NULL, 0));
846+
break;
847+
}
847848

848849
case CONTROL_STAGE_ACK: {
849850
// Abort all pending transfers if SET_CONFIGURATION request

src/portable/ehci/ehci.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ static void ehci_enable_schedule(ehci_registers_t* regs, bool is_period) {
184184
//--------------------------------------------------------------------+
185185
uint32_t hcd_frame_number(uint8_t rhport) {
186186
(void) rhport;
187-
return (ehci_data.uframe_number + ehci_data.regs->frame_index) >> 3;
187+
uint32_t uframe = ehci_data.regs->frame_index;
188+
return (ehci_data.uframe_number + uframe) >> 3;
188189
}
189190

190191
void hcd_port_reset(uint8_t rhport) {
@@ -896,7 +897,7 @@ static void qhd_init(ehci_qhd_t *p_qhd, uint8_t dev_addr, tusb_desc_endpoint_t c
896897
p_qhd->used = 1;
897898
p_qhd->removing = 0;
898899
p_qhd->attached_qtd = NULL;
899-
p_qhd->pid = tu_edpt_dir(ep_desc->bEndpointAddress) ? EHCI_PID_IN : EHCI_PID_OUT; // PID for TD under this endpoint
900+
p_qhd->pid = tu_edpt_dir(ep_desc->bEndpointAddress) == TUSB_DIR_IN ? EHCI_PID_IN : EHCI_PID_OUT; // PID for TD under this endpoint
900901

901902
//------------- active, but no TD list -------------//
902903
p_qhd->qtd_overlay.halted = 0;

0 commit comments

Comments
 (0)