Add -Wuninitialized -Wunused -Wcast-align to warnings checked by kitchen_sink (and fixup warnings) (#125)

This commit is contained in:
Graham Sanderson 2021-02-15 10:06:12 -06:00 committed by GitHub
parent 81c3d3fae6
commit 8b9907e7f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 32 additions and 31 deletions

View File

@ -253,8 +253,9 @@ static void alarm_pool_dump_key(pheap_node_id_t id, void *user_data) {
#endif #endif
} }
static int64_t repeating_timer_callback(alarm_id_t id, void *user_data) { static int64_t repeating_timer_callback(__unused alarm_id_t id, __unused void *user_data) {
repeating_timer_t *rt = (repeating_timer_t *)user_data; repeating_timer_t *rt = (repeating_timer_t *)user_data;
assert(rt->alarm_id == id);
if (rt->callback(rt)) { if (rt->callback(rt)) {
return rt->delay_us; return rt->delay_us;
} else { } else {
@ -289,7 +290,7 @@ void alarm_pool_dump(alarm_pool_t *pool) {
} }
#if !PICO_TIME_DEFAULT_ALARM_POOL_DISABLED #if !PICO_TIME_DEFAULT_ALARM_POOL_DISABLED
static int64_t sev_callback(alarm_id_t id, void *user_data) { static int64_t sev_callback(__unused alarm_id_t id, __unused void *user_data) {
__sev(); __sev();
return 0; return 0;
} }

View File

@ -42,7 +42,7 @@ extern "C" {
#define PARAM_ASSERTIONS_ENABLED_DMA 0 #define PARAM_ASSERTIONS_ENABLED_DMA 0
#endif #endif
static inline void check_dma_channel_param(uint channel) { static inline void check_dma_channel_param(__unused uint channel) {
#if PARAM_ASSERTIONS_ENABLED(DMA) #if PARAM_ASSERTIONS_ENABLED(DMA)
// this method is used a lot by inline functions so avoid code bloat by deferring to function // this method is used a lot by inline functions so avoid code bloat by deferring to function
extern void check_dma_channel_param_impl(uint channel); extern void check_dma_channel_param_impl(uint channel);

View File

@ -169,6 +169,7 @@ static_assert(FLASH_UNIQUE_ID_SIZE_BYTES == FLASH_RUID_DATA_BYTES, "");
void flash_get_unique_id(uint8_t *id_out) { void flash_get_unique_id(uint8_t *id_out) {
#if PICO_NO_FLASH #if PICO_NO_FLASH
__unused uint8_t *ignore = id_out;
panic_unsupported(); panic_unsupported();
#else #else
uint8_t txbuf[FLASH_RUID_TOTAL_BYTES] = {0}; uint8_t txbuf[FLASH_RUID_TOTAL_BYTES] = {0};

View File

@ -34,7 +34,7 @@ static void set_raw_irq_handler_and_unlock(uint num, irq_handler_t handler, uint
spin_unlock(spin_lock_instance(PICO_SPINLOCK_ID_IRQ), save); spin_unlock(spin_lock_instance(PICO_SPINLOCK_ID_IRQ), save);
} }
static inline void check_irq_param(uint num) { static inline void check_irq_param(__unused uint num) {
invalid_params_if(IRQ, num >= NUM_IRQS); invalid_params_if(IRQ, num >= NUM_IRQS);
} }

View File

@ -104,7 +104,7 @@ typedef struct {
uint32_t pinctrl; uint32_t pinctrl;
} pio_sm_config; } pio_sm_config;
static inline void check_sm_param(uint sm) { static inline void check_sm_param(__unused uint sm) {
valid_params_if(PIO, sm < NUM_PIO_STATE_MACHINES); valid_params_if(PIO, sm < NUM_PIO_STATE_MACHINES);
} }

View File

@ -50,13 +50,6 @@ int pio_claim_unused_sm(PIO pio, bool required) {
return index >= base ? index - base : -1; return index >= base ? index - base : -1;
} }
void pio_load_program(PIO pio, const uint16_t *prog, uint8_t prog_len, uint8_t load_offset) {
// instructions are only 16 bits, but instruction memory locations are spaced 32 bits apart
// Adjust the addresses of any jump instructions to respect load offset
assert(load_offset + prog_len <= PIO_INSTRUCTION_COUNT);
}
static_assert(PIO_INSTRUCTION_COUNT <= 32, ""); static_assert(PIO_INSTRUCTION_COUNT <= 32, "");
static uint32_t _used_instruction_space[2]; static uint32_t _used_instruction_space[2];

View File

@ -136,7 +136,7 @@ static inline spi_hw_t *spi_get_hw(spi_inst_t *spi) {
* \param cpha SSPCLKOUT phase, applicable to Motorola SPI frame format only * \param cpha SSPCLKOUT phase, applicable to Motorola SPI frame format only
* \param order Must be SPI_MSB_FIRST, no other values supported on the PL022 * \param order Must be SPI_MSB_FIRST, no other values supported on the PL022
*/ */
static inline void spi_set_format(spi_inst_t *spi, uint data_bits, spi_cpol_t cpol, spi_cpha_t cpha, spi_order_t order) { static inline void spi_set_format(spi_inst_t *spi, uint data_bits, spi_cpol_t cpol, spi_cpha_t cpha, __unused spi_order_t order) {
invalid_params_if(SPI, data_bits < 4 || data_bits > 16); invalid_params_if(SPI, data_bits < 4 || data_bits > 16);
// LSB-first not supported on PL022: // LSB-first not supported on PL022:
invalid_params_if(SPI, order != SPI_MSB_FIRST); invalid_params_if(SPI, order != SPI_MSB_FIRST);

View File

@ -50,7 +50,7 @@ extern "C" {
#define PARAM_ASSERTIONS_ENABLED_TIMER 0 #define PARAM_ASSERTIONS_ENABLED_TIMER 0
#endif #endif
static inline void check_hardware_alarm_num_param(uint alarm_num) { static inline void check_hardware_alarm_num_param(__unused uint alarm_num) {
invalid_params_if(TIMER, alarm_num >= NUM_TIMERS); invalid_params_if(TIMER, alarm_num >= NUM_TIMERS);
} }

View File

@ -38,7 +38,7 @@ static inline uint8_t hw_line_state(void) {
return (usb_hw->sie_status & USB_SIE_STATUS_LINE_STATE_BITS) >> USB_SIE_STATUS_LINE_STATE_LSB; return (usb_hw->sie_status & USB_SIE_STATUS_LINE_STATE_BITS) >> USB_SIE_STATUS_LINE_STATE_LSB;
} }
int64_t hw_enumeration_fix_wait_se0_callback(alarm_id_t id, void *user_data) { int64_t hw_enumeration_fix_wait_se0_callback(__unused alarm_id_t id, __unused void *user_data) {
if (hw_line_state() == LS_SE0) { if (hw_line_state() == LS_SE0) {
// Come back in 1ms and check again // Come back in 1ms and check again
return 1000; return 1000;
@ -71,7 +71,7 @@ static void hw_enumeration_fix_wait_se0(void) {
hw_enumeration_fix_busy_wait_se0(); hw_enumeration_fix_busy_wait_se0();
} }
int64_t hw_enumeration_fix_force_ls_j_done(alarm_id_t id, void *user_data) { int64_t hw_enumeration_fix_force_ls_j_done(__unused alarm_id_t id, __unused void *user_data) {
hw_enumeration_fix_finish(); hw_enumeration_fix_finish();
return 0; return 0;
} }

View File

@ -19,7 +19,7 @@ extern void __real_free(void *mem);
extern char __StackLimit; /* Set by linker. */ extern char __StackLimit; /* Set by linker. */
static inline void check_alloc(void *mem, uint8_t size) { static inline void check_alloc(__unused void *mem, __unused uint8_t size) {
#if PICO_MALLOC_PANIC #if PICO_MALLOC_PANIC
if (!mem || (((char *)mem) + size) > &__StackLimit) { if (!mem || (((char *)mem) + size) > &__StackLimit) {
panic("Out of memory"); panic("Out of memory");

View File

@ -83,6 +83,8 @@ int core1_wrapper(int (*entry)(void), void *stack_base) {
#if PICO_USE_STACK_GUARDS #if PICO_USE_STACK_GUARDS
// install core1 stack guard // install core1 stack guard
runtime_install_stack_guard(stack_base); runtime_install_stack_guard(stack_base);
#else
__unused void *ignore = stack_base;
#endif #endif
irq_init_priorities(); irq_init_priorities();
return (*entry)(); return (*entry)();
@ -126,7 +128,7 @@ void multicore_launch_core1_with_stack(void (*entry)(void), uint32_t *stack_bott
} }
void multicore_launch_core1(void (*entry)(void)) { void multicore_launch_core1(void (*entry)(void)) {
extern char __StackOneBottom; extern uint32_t __StackOneBottom;
uint32_t *stack_limit = (uint32_t *) &__StackOneBottom; uint32_t *stack_limit = (uint32_t *) &__StackOneBottom;
// hack to reference core1_stack although that pointer is wrong.... core1_stack should always be <= stack_limit, if not boom! // hack to reference core1_stack although that pointer is wrong.... core1_stack should always be <= stack_limit, if not boom!
uint32_t *stack = core1_stack <= stack_limit ? stack_limit : (uint32_t *) -1; uint32_t *stack = core1_stack <= stack_limit ? stack_limit : (uint32_t *) -1;

View File

@ -156,7 +156,7 @@ void runtime_init(void) {
} }
void _exit(int status) { void _exit(__unused int status) {
#if PICO_ENTER_USB_BOOT_ON_EXIT #if PICO_ENTER_USB_BOOT_ON_EXIT
reset_usb_boot(0,0); reset_usb_boot(0,0);
#else #else

View File

@ -17,7 +17,7 @@ void *operator new[](std::size_t n) {
return std::malloc(n); return std::malloc(n);
} }
void operator delete(void *p, std::size_t n) noexcept { std::free(p); } void operator delete(void *p, __unused std::size_t n) noexcept { std::free(p); }
void operator delete(void *p) { std::free(p); } void operator delete(void *p) { std::free(p); }

View File

@ -42,6 +42,11 @@ target_link_libraries(kitchen_sink_libs INTERFACE
pico_unique_id pico_unique_id
pico_util pico_util
) )
# todo this is full of warnings atm
#if (TARGET tinyusb_device)
# target_include_directories(kitchen_sink_libs INTERFACE ${CMAKE_CURRENT_LIST_DIR})
# target_link_libraries(kitchen_sink_libs INTERFACE tinyusb_device)
#endif()
add_library(kitchen_sink_options INTERFACE) add_library(kitchen_sink_options INTERFACE)
@ -49,23 +54,27 @@ target_compile_options(kitchen_sink_options INTERFACE
-Werror -Werror
-Wall -Wall
-Wextra -Wextra
-Wno-unused-parameter # -pedantic
-Wno-inline
-Wnull-dereference -Wnull-dereference
# -pedantic -Wuninitialized
-Wunused
-Wcast-align
-Wall -Wall
-Wcast-qual -Wcast-qual
-Wno-deprecated-declarations
-Wfloat-equal -Wfloat-equal
-Wmissing-format-attribute -Wmissing-format-attribute
-Wno-long-long
$<$<COMPILE_LANGUAGE:C>:-Wstrict-prototypes> $<$<COMPILE_LANGUAGE:C>:-Wstrict-prototypes>
-Wno-inline
# todo not sure these are true, but investigate # todo not sure these are true, but investigate
#-Wpacked #-Wpacked
# todo requires unsigned register constants
#-Wconversion
# todo we have some of these in usb_device_tiny to try to make it more readable.. perhaps doxygen would help here instead # todo we have some of these in usb_device_tiny to try to make it more readable.. perhaps doxygen would help here instead
#-Wredundant-decls -Wredundant-decls
-Wno-shadow -Wno-shadow
-Wno-missing-field-initializers -Wno-missing-field-initializers
-Wno-missing-braces -Wno-missing-braces

View File

@ -27,10 +27,6 @@ bi_decl(bi_block_device(
BINARY_INFO_BLOCK_DEV_FLAG_READ | BINARY_INFO_BLOCK_DEV_FLAG_WRITE | BINARY_INFO_BLOCK_DEV_FLAG_READ | BINARY_INFO_BLOCK_DEV_FLAG_WRITE |
BINARY_INFO_BLOCK_DEV_FLAG_PT_UNKNOWN)); BINARY_INFO_BLOCK_DEV_FLAG_PT_UNKNOWN));
void my_timer(uint i) {
puts("XXXX timer");
}
//#pragma GCC push_options //#pragma GCC push_options
//#pragma GCC optimize ("O3") //#pragma GCC optimize ("O3")
@ -87,7 +83,6 @@ int main(void) {
dma_channel_configure(0, &config, &dma_to, &dma_from, 1, true); dma_channel_configure(0, &config, &dma_to, &dma_from, 1, true);
dma_channel_set_config(0, &config, false); dma_channel_set_config(0, &config, false);
// timer_start_ms(2, 2000, my_timer);
for (int i = 0; i < 20; i++) { for (int i = 0; i < 20; i++) {
puts("sleepy"); puts("sleepy");
sleep_ms(1000); sleep_ms(1000);