Merge pull request #411 from hathach/fix-cast-align-warning

enable -Wcast-align
This commit is contained in:
Ha Thach 2020-05-18 13:21:37 +07:00 committed by GitHub
commit 76bf96bcb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 54 additions and 42 deletions

View File

@ -6,6 +6,9 @@ CFLAGS += \
-DTCP_WND=2*TCP_MSS \
-DHTTPD_USE_CUSTOM_FSDATA=0
# TODO rndis_reports.c and net_device cause cast algin warnings
CFLAGS += -Wno-error=cast-align
INC += \
src \
$(TOP)/hw \

View File

@ -63,11 +63,9 @@ CFLAGS += \
-Wwrite-strings \
-Wsign-compare \
-Wmissing-format-attribute \
-Wunreachable-code
# This causes lots of warning with nrf5x build due to nrfx code
# CFLAGS += -Wcast-align
-Wunreachable-code \
-Wcast-align
# Debugging/Optimization
ifeq ($(DEBUG), 1)
CFLAGS += -Og -ggdb

View File

@ -9,8 +9,8 @@ CFLAGS += \
-DNRF52840_XXAA \
-DCONFIG_GPIO_AS_PINRESET
# nrfx issue undef _ARMCC_VERSION usage https://github.com/NordicSemiconductor/nrfx/issues/49
CFLAGS += -Wno-error=undef -Wno-error=unused-parameter
# suppress warning caused by vendor mcu driver
CFLAGS += -Wno-error=undef -Wno-error=unused-parameter -Wno-error=cast-align
# due to tusb_hal_nrf_power_event
GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion)))

View File

@ -9,8 +9,8 @@ CFLAGS += \
-DNRF52840_XXAA \
-DCONFIG_GPIO_AS_PINRESET
# nrfx issue undef _ARMCC_VERSION usage https://github.com/NordicSemiconductor/nrfx/issues/49
CFLAGS += -Wno-error=undef -Wno-error=unused-parameter
# suppress warning caused by vendor mcu driver
CFLAGS += -Wno-error=undef -Wno-error=unused-parameter -Wno-error=cast-align
# due to tusb_hal_nrf_power_event
GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion)))

View File

@ -9,8 +9,8 @@ CFLAGS += \
-DNRF52840_XXAA \
-DCONFIG_GPIO_AS_PINRESET
# nrfx issue undef _ARMCC_VERSION usage https://github.com/NordicSemiconductor/nrfx/issues/49
CFLAGS += -Wno-error=undef -Wno-error=unused-parameter
# suppress warning caused by vendor mcu driver
CFLAGS += -Wno-error=undef -Wno-error=unused-parameter -Wno-error=cast-align
# due to tusb_hal_nrf_power_event
GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion)))

View File

@ -9,8 +9,8 @@ CFLAGS += \
-DNRF52840_XXAA \
-DCONFIG_GPIO_AS_PINRESET
# nrfx issue undef _ARMCC_VERSION usage https://github.com/NordicSemiconductor/nrfx/issues/49
CFLAGS += -Wno-error=undef -Wno-error=unused-parameter
# suppress warning caused by vendor mcu driver
CFLAGS += -Wno-error=undef -Wno-error=unused-parameter -Wno-error=cast-align
# due to tusb_hal_nrf_power_event
GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion)))

View File

@ -9,8 +9,8 @@ CFLAGS += \
-DNRF52840_XXAA \
-DCONFIG_GPIO_AS_PINRESET
# nrfx issue undef _ARMCC_VERSION usage https://github.com/NordicSemiconductor/nrfx/issues/49
CFLAGS += -Wno-error=undef -Wno-error=unused-parameter
# suppress warning caused by vendor mcu driver
CFLAGS += -Wno-error=undef -Wno-error=unused-parameter -Wno-error=cast-align
# due to tusb_hal_nrf_power_event
GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion)))

View File

@ -9,6 +9,9 @@ CFLAGS += \
-DSTM32F405xx \
-DCFG_TUSB_MCU=OPT_MCU_STM32F4
# suppress warning caused by vendor mcu driver
CFLAGS += -Wno-error=cast-align
ST_HAL_DRIVER = hw/mcu/st/st_driver/STM32F4xx_HAL_Driver
ST_CMSIS = hw/mcu/st/st_driver/CMSIS/Device/ST/STM32F4xx

View File

@ -8,8 +8,8 @@ CFLAGS += \
-DNRF52840_XXAA \
-DCFG_TUSB_MCU=OPT_MCU_NRF5X
# nrfx issue undef _ARMCC_VERSION usage https://github.com/NordicSemiconductor/nrfx/issues/49
CFLAGS += -Wno-error=undef -Wno-error=unused-parameter
# suppress warning caused by vendor mcu driver
CFLAGS += -Wno-error=undef -Wno-error=unused-parameter -Wno-error=cast-align
# due to tusb_hal_nrf_power_event
GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion)))

View File

@ -19,13 +19,11 @@ SRC_C += \
hw/mcu/nuvoton/nuc505/StdDriver/src/i2s.c \
hw/mcu/nuvoton/nuc505/StdDriver/src/pwm.c \
hw/mcu/nuvoton/nuc505/StdDriver/src/rtc.c \
hw/mcu/nuvoton/nuc505/StdDriver/src/sd.c \
hw/mcu/nuvoton/nuc505/StdDriver/src/spi.c \
hw/mcu/nuvoton/nuc505/StdDriver/src/spim.c \
hw/mcu/nuvoton/nuc505/StdDriver/src/sys.c \
hw/mcu/nuvoton/nuc505/StdDriver/src/timer.c \
hw/mcu/nuvoton/nuc505/StdDriver/src/uart.c \
hw/mcu/nuvoton/nuc505/StdDriver/src/usbd.c \
hw/mcu/nuvoton/nuc505/StdDriver/src/wdt.c \
hw/mcu/nuvoton/nuc505/StdDriver/src/wwdt.c

View File

@ -9,8 +9,8 @@ CFLAGS += \
-DCONFIG_GPIO_AS_PINRESET \
-DCFG_TUSB_MCU=OPT_MCU_NRF5X
# nrfx issue undef _ARMCC_VERSION usage https://github.com/NordicSemiconductor/nrfx/issues/49
CFLAGS += -Wno-error=undef -Wno-error=unused-parameter
# suppress warning caused by vendor mcu driver
CFLAGS += -Wno-error=undef -Wno-error=unused-parameter -Wno-error=cast-align
# due to tusb_hal_nrf_power_event
GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion)))

View File

@ -9,8 +9,8 @@ CFLAGS += \
-DCONFIG_GPIO_AS_PINRESET \
-DCFG_TUSB_MCU=OPT_MCU_NRF5X
# nrfx issue undef _ARMCC_VERSION usage https://github.com/NordicSemiconductor/nrfx/issues/49
CFLAGS += -Wno-error=undef -Wno-error=unused-parameter
# suppress warning caused by vendor mcu driver
CFLAGS += -Wno-error=undef -Wno-error=unused-parameter -Wno-error=cast-align
# due to tusb_hal_nrf_power_event
GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion)))

View File

@ -9,8 +9,8 @@ CFLAGS += \
-DCONFIG_GPIO_AS_PINRESET \
-DCFG_TUSB_MCU=OPT_MCU_NRF5X
# nrfx issue undef _ARMCC_VERSION usage https://github.com/NordicSemiconductor/nrfx/issues/49
CFLAGS += -Wno-error=undef -Wno-error=unused-parameter
# suppress warning caused by vendor mcu driver
CFLAGS += -Wno-error=undef -Wno-error=unused-parameter -Wno-error=cast-align
# due to tusb_hal_nrf_power_event
GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion)))

View File

@ -8,8 +8,8 @@ CFLAGS += \
-DNRF52840_XXAA \
-DCFG_TUSB_MCU=OPT_MCU_NRF5X
# nrfx issue undef _ARMCC_VERSION usage https://github.com/NordicSemiconductor/nrfx/issues/49
CFLAGS += -Wno-error=undef -Wno-error=unused-parameter
# suppress warning caused by vendor mcu driver
CFLAGS += -Wno-error=undef -Wno-error=unused-parameter -Wno-error=cast-align
# due to tusb_hal_nrf_power_event
GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion)))

View File

@ -9,8 +9,8 @@ CFLAGS += \
-DCFG_EXAMPLE_MSC_READONLY \
-DCFG_TUSB_MCU=OPT_MCU_STM32F0
# mcu driver cause following warnings
CFLAGS += -Wno-error=unused-parameter
# suppress warning caused by vendor mcu driver
CFLAGS += -Wno-error=unused-parameter -Wno-error=cast-align
ST_HAL_DRIVER = hw/mcu/st/st_driver/STM32F0xx_HAL_Driver
ST_CMSIS = hw/mcu/st/st_driver/CMSIS/Device/ST/STM32F0xx

View File

@ -9,8 +9,8 @@ CFLAGS += \
-DCFG_EXAMPLE_MSC_READONLY \
-DCFG_TUSB_MCU=OPT_MCU_STM32F0
# mcu driver cause following warnings
CFLAGS += -Wno-error=unused-parameter
# suppress warning caused by vendor mcu driver
CFLAGS += -Wno-error=unused-parameter -Wno-error=cast-align
ST_HAL_DRIVER = hw/mcu/st/st_driver/STM32F0xx_HAL_Driver
ST_CMSIS = hw/mcu/st/st_driver/CMSIS/Device/ST/STM32F0xx

View File

@ -9,6 +9,9 @@ CFLAGS += \
-DSTM32F407xx \
-DCFG_TUSB_MCU=OPT_MCU_STM32F4
# suppress warning caused by vendor mcu driver
CFLAGS += -Wno-error=cast-align
ST_HAL_DRIVER = hw/mcu/st/st_driver/STM32F4xx_HAL_Driver
ST_CMSIS = hw/mcu/st/st_driver/CMSIS/Device/ST/STM32F4xx

View File

@ -9,6 +9,9 @@ CFLAGS += \
-DSTM32F411xE \
-DCFG_TUSB_MCU=OPT_MCU_STM32F4
# suppress warning caused by vendor mcu driver
CFLAGS += -Wno-error=cast-align
ST_HAL_DRIVER = hw/mcu/st/st_driver/STM32F4xx_HAL_Driver
ST_CMSIS = hw/mcu/st/st_driver/CMSIS/Device/ST/STM32F4xx

View File

@ -9,8 +9,8 @@ CFLAGS += \
-DSTM32F412Zx \
-DCFG_TUSB_MCU=OPT_MCU_STM32F4
# mcu driver cause following warnings
CFLAGS += -Wno-error=maybe-uninitialized
# suppress warning caused by vendor mcu driver
CFLAGS += -Wno-error=cast-align
ST_HAL_DRIVER = hw/mcu/st/st_driver/STM32F4xx_HAL_Driver
ST_CMSIS = hw/mcu/st/st_driver/CMSIS/Device/ST/STM32F4xx

View File

@ -9,8 +9,8 @@ CFLAGS += \
-DSTM32F746xx \
-DCFG_TUSB_MCU=OPT_MCU_STM32F7
# mcu driver cause following warnings
CFLAGS += -Wno-error=shadow
# suppress warning caused by vendor mcu driver
CFLAGS += -Wno-error=cast-align -Wno-error=shadow
ST_HAL_DRIVER = hw/mcu/st/st_driver/STM32F7xx_HAL_Driver
ST_CMSIS = hw/mcu/st/st_driver/CMSIS/Device/ST/STM32F7xx

View File

@ -9,8 +9,8 @@ CFLAGS += \
-DSTM32F767xx \
-DCFG_TUSB_MCU=OPT_MCU_STM32F7
# mcu driver cause following warnings
CFLAGS += -Wno-error=shadow
# suppress warning caused by vendor mcu driver
CFLAGS += -Wno-error=cast-align -Wno-error=shadow
ST_HAL_DRIVER = hw/mcu/st/st_driver/STM32F7xx_HAL_Driver
ST_CMSIS = hw/mcu/st/st_driver/CMSIS/Device/ST/STM32F7xx

View File

@ -10,7 +10,6 @@ CFLAGS += \
-DCFG_TUSB_MCU=OPT_MCU_STM32H7
# mcu driver cause following warnings
CFLAGS += -Wno-error=maybe-uninitialized
ST_HAL_DRIVER = hw/mcu/st/st_driver/STM32H7xx_HAL_Driver
ST_CMSIS = hw/mcu/st/st_driver/CMSIS/Device/ST/STM32H7xx

View File

@ -106,7 +106,7 @@ static inline uint16_t tu_max16 (uint16_t x, uint16_t y) { return (x > y) ? x :
static inline uint32_t tu_max32 (uint32_t x, uint32_t y) { return (x > y) ? x : y; }
// Align
static inline uint32_t tu_align_n(uint32_t value, uint32_t alignment)
static inline uint32_t tu_align(uint32_t value, uint32_t alignment)
{
return value & ((uint32_t) ~(alignment-1));
}

View File

@ -182,7 +182,10 @@ static void dcd_userEP_in_xfer(struct xfer_ctl_t *xfer, USBD_EP_T *ep)
/* provided buffers are thankfully 32-bit aligned, allowing most data to be transfered as 32-bit */
while (countdown > 3)
{
ep->EPDAT = *(uint32_t *)xfer->data_ptr;
uint32_t u32;
memcpy(&u32, xfer->data_ptr, 4);
ep->EPDAT = u32;
xfer->data_ptr += 4; countdown -= 4;
}
while (countdown--)

View File

@ -273,7 +273,8 @@ typedef struct {
dcd_qtd_t qtd[QHD_MAX] TU_ATTR_ALIGNED(32); // for portability, TinyUSB only queue 1 TD for each Qhd
}dcd_data_t;
static dcd_data_t _dcd_data CFG_TUSB_MEM_SECTION TU_ATTR_ALIGNED(2048);
CFG_TUSB_MEM_SECTION TU_ATTR_ALIGNED(2048)
static dcd_data_t _dcd_data;
//--------------------------------------------------------------------+
// CONTROLLER API
@ -478,7 +479,8 @@ bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t t
// Force the CPU to flush the buffer. We increase the size by 32 because the call aligns the
// address to 32-byte boundaries.
CleanInvalidateDCache_by_Addr((uint32_t*) buffer, total_bytes + 31);
// void* cast to suppress cast-align warning, buffer must be
CleanInvalidateDCache_by_Addr((uint32_t*) tu_align((uint32_t) buffer, 4), total_bytes + 31);
//------------- Prepare qtd -------------//
qtd_init(p_qtd, buffer, total_bytes);