diff --git a/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c b/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c index 59f1551111..742d5f2458 100644 --- a/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c +++ b/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c @@ -965,7 +965,8 @@ void dcd_edpt_close (uint8_t rhport, uint8_t ep_addr) (void)rhport; xfer_ctl_t * xfer = xfer_ctl_ptr(ep_addr); - uint8_t const epnum = xfer->epnum; + // Fix -Werror=null-dereference + uint8_t const epnum = ((xfer_ctl_t *)xfer)->epnum; uint8_t const dir = tu_edpt_dir(ep_addr); if(dir == TUSB_DIR_IN) @@ -1004,7 +1005,6 @@ bool dcd_edpt_iso_activate(uint8_t rhport, tusb_desc_endpoint_t const * p_endpo { (void)rhport; uint8_t const epnum = xfer_ctl_ptr(p_endpoint_desc->bEndpointAddress)->epnum; - uint8_t const dir = tu_edpt_dir(p_endpoint_desc->bEndpointAddress); const uint16_t packet_size = tu_edpt_packet_size(p_endpoint_desc); uint16_t pma_addr; @@ -1071,7 +1071,8 @@ bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t (void) rhport; xfer_ctl_t * xfer = xfer_ctl_ptr(ep_addr); - uint8_t const epnum = xfer->epnum; + // Fix -Werror=null-dereference + uint8_t const epnum = ((xfer_ctl_t *)xfer)->epnum; uint8_t const dir = tu_edpt_dir(ep_addr); xfer->buffer = buffer; @@ -1108,7 +1109,8 @@ bool dcd_edpt_xfer_fifo (uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16 (void) rhport; xfer_ctl_t * xfer = xfer_ctl_ptr(ep_addr); - uint8_t const epnum = xfer->epnum; + // Fix -Werror=null-dereference + uint8_t const epnum = ((xfer_ctl_t *)xfer)->epnum; uint8_t const dir = tu_edpt_dir(ep_addr); xfer->buffer = NULL; @@ -1138,7 +1140,8 @@ void dcd_edpt_stall (uint8_t rhport, uint8_t ep_addr) (void)rhport; xfer_ctl_t * xfer = xfer_ctl_ptr(ep_addr); - uint8_t const epnum = xfer->epnum; + // Fix -Werror=null-dereference + uint8_t const epnum = ((xfer_ctl_t *)xfer)->epnum; uint8_t const dir = tu_edpt_dir(ep_addr); if (dir == TUSB_DIR_IN) @@ -1156,7 +1159,8 @@ void dcd_edpt_clear_stall (uint8_t rhport, uint8_t ep_addr) (void)rhport; xfer_ctl_t * xfer = xfer_ctl_ptr(ep_addr); - uint8_t const epnum = xfer->epnum; + // Fix -Werror=null-dereference + uint8_t const epnum = ((xfer_ctl_t *)xfer)->epnum; uint8_t const dir = tu_edpt_dir(ep_addr); if (dir == TUSB_DIR_IN) diff --git a/src/portable/st/stm32_fsdev/dcd_stm32_fsdev_pvt_st.h b/src/portable/st/stm32_fsdev/dcd_stm32_fsdev_pvt_st.h index b64776fc95..3823746146 100644 --- a/src/portable/st/stm32_fsdev/dcd_stm32_fsdev_pvt_st.h +++ b/src/portable/st/stm32_fsdev/dcd_stm32_fsdev_pvt_st.h @@ -234,7 +234,7 @@ TU_ATTR_ALWAYS_INLINE static inline void pcd_set_ep_cnt_reg(__O uint16_t * pdwRe /* There should be no remainder in the above calculation */ TU_ASSERT((wCount - (numblocks * (blocksize ? 32 : 2))) == 0, /**/); - /* Encode into register. When BLSIZE==1, we need to substract 1 block count */ + /* Encode into register. When BLSIZE==1, we need to subtract 1 block count */ *pdwReg = (blocksize << 15) | ((numblocks - blocksize) << 10); }