浏览代码

enable -Wnull-dereference

hathach 4 年之前
父节点
当前提交
826b34a8ac
共有 3 个文件被更改,包括 9 次插入3 次删除
  1. 2 1
      examples/make.mk
  2. 1 1
      hw/bsp/samg55xplained/board.mk
  3. 6 1
      src/portable/nuvoton/nuc505/dcd_nuc505.c

+ 2 - 1
examples/make.mk

@@ -105,7 +105,8 @@ CFLAGS += \
   -Wunreachable-code \
   -Wcast-align \
   -Wcast-function-type \
-  -Wcast-qual
+  -Wcast-qual \
+  -Wnull-dereference
 
 # Debugging/Optimization
 ifeq ($(DEBUG), 1)

+ 1 - 1
hw/bsp/samg55xplained/board.mk

@@ -12,7 +12,7 @@ CFLAGS += \
   -DCFG_TUSB_MCU=OPT_MCU_SAMG
 
 # suppress following warnings from mcu driver
-CFLAGS += -Wno-error=undef -Wno-error=cast-qual
+CFLAGS += -Wno-error=undef -Wno-error=cast-qual -Wno-error=null-dereference
 
 ASF_DIR = hw/mcu/microchip/samg55
 

+ 6 - 1
src/portable/nuvoton/nuc505/dcd_nuc505.c

@@ -144,7 +144,9 @@ static USBD_EP_T *ep_entry(uint8_t ep_addr, bool add)
   enum ep_enum ep_index;
   struct xfer_ctl_t *xfer;
 
-  for (ep_index = PERIPH_EPA, xfer = &xfer_table[PERIPH_EPA], ep = USBD->EP; ep_index < PERIPH_MAX_EP; ep_index++, xfer++, ep++)
+  for (ep_index = PERIPH_EPA, xfer = &xfer_table[PERIPH_EPA], ep = USBD->EP;
+       ep_index < PERIPH_MAX_EP;
+       ep_index++, xfer++, ep++)
   {
     if (add)
     {
@@ -396,6 +398,7 @@ bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t *buffer, uint16_t to
     /* mine the data for the information we need */
     tusb_dir_t dir = tu_edpt_dir(ep_addr);
     USBD_EP_T *ep = ep_entry(ep_addr, false);
+    TU_ASSERT(ep);
     struct xfer_ctl_t *xfer = &xfer_table[ep - USBD->EP];
 
     /* store away the information we'll needing now and later */
@@ -457,6 +460,7 @@ void dcd_edpt_stall(uint8_t rhport, uint8_t ep_addr)
   if (tu_edpt_number(ep_addr))
   {
     USBD_EP_T *ep = ep_entry(ep_addr, false);
+    TU_ASSERT(ep, );
     ep->EPRSPCTL = (ep->EPRSPCTL & 0xf7) | USBD_EPRSPCTL_HALT_Msk;
   }
   else
@@ -472,6 +476,7 @@ void dcd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr)
   if (tu_edpt_number(ep_addr))
   {
     USBD_EP_T *ep = ep_entry(ep_addr, false);
+    TU_ASSERT(ep, );
     ep->EPRSPCTL = USBD_EPRSPCTL_TOGGLE_Msk;
   }
 }