fix warnings cast function type for nrf, fix pico osal warning

add TODO for overflow in tusb_fifo.c
This commit is contained in:
hathach 2021-05-25 21:02:40 +07:00
parent ca8724ee08
commit 954056da0c
No known key found for this signature in database
GPG Key ID: 2FA891220FBFD581
4 changed files with 13 additions and 2 deletions

View File

@ -88,6 +88,7 @@ CFLAGS += \
-fno-strict-aliasing \
-Wdouble-promotion \
-Wstrict-prototypes \
-Wstrict-overflow \
-Wall \
-Wextra \
-Werror \
@ -100,7 +101,8 @@ CFLAGS += \
-Wsign-compare \
-Wmissing-format-attribute \
-Wunreachable-code \
-Wcast-align
-Wcast-align \
-Wcast-function-type
# Debugging/Optimization
ifeq ($(DEBUG), 1)

View File

@ -55,6 +55,11 @@ static nrfx_uarte_t _uart_id = NRFX_UARTE_INSTANCE(0);
// We must call it within SD's SOC event handler, or set it as power event handler if SD is not enabled.
extern void tusb_hal_nrf_power_event(uint32_t event);
static void power_event_handler(nrfx_power_usb_evt_t event)
{
tusb_hal_nrf_power_event((uint32_t) event);
}
void board_init(void)
{
// stop LF clock just in case we jump from application without reset
@ -121,7 +126,7 @@ void board_init(void)
// Register tusb function as USB power handler
// cause cast-function-type warning
const nrfx_power_usbevt_config_t config = { .handler = ((nrfx_power_usb_event_handler_t) tusb_hal_nrf_power_event) };
const nrfx_power_usbevt_config_t config = { .handler = power_event_handler };
nrfx_power_usbevt_init(&config);
nrfx_power_usbevt_enable();

View File

@ -325,6 +325,8 @@ static uint16_t advance_pointer(tu_fifo_t* f, uint16_t p, uint16_t offset)
// We limit the index space of p such that a correct wrap around happens
// Check for a wrap around or if we are in unused index space - This has to be checked first!!
// We are exploiting the wrap around to the correct index
// TODO warning: assuming signed overflow does not occur when assuming that (X + c) < X is always false [-Wstrict-overflow]
if ((p > p + offset) || (p + offset > f->max_pointer_idx))
{
p = (p + offset) + f->non_used_index_space;

View File

@ -57,6 +57,7 @@ static inline osal_semaphore_t osal_semaphore_create(osal_semaphore_def_t* semde
static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr)
{
(void) in_isr;
sem_release(sem_hdl);
return true;
}
@ -158,6 +159,7 @@ static inline bool osal_queue_send(osal_queue_t qhdl, void const * data, bool in
// however osal_queue_recieve may be. therefore my assumption is that
// the fifo mutex is not populated for queues used from an IRQ context
//assert(!qhdl->ff.mutex);
(void) in_isr;
_osal_q_lock(qhdl);
bool success = tu_fifo_write(&qhdl->ff, data);