From c9475adb00b082f2e0444cbb262647fd1009d076 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 10 Nov 2021 11:07:45 -0600 Subject: [PATCH] Enable -Werror=missing-prototypes on espressif port --- ports/espressif/Makefile | 2 +- ports/espressif/background.c | 1 + ports/espressif/bindings/espidf/__init__.c | 10 +--------- ports/espressif/cam.c | 6 +++--- ports/espressif/common-hal/alarm/SleepMemory.c | 1 + ports/espressif/common-hal/alarm/pin/PinAlarm.c | 2 +- ports/espressif/common-hal/alarm/time/TimeAlarm.c | 2 +- ports/espressif/common-hal/alarm/touch/TouchAlarm.c | 2 +- ports/espressif/common-hal/analogio/AnalogIn.c | 1 + ports/espressif/common-hal/canio/CAN.c | 4 ++-- ports/espressif/common-hal/canio/Listener.c | 2 +- ports/espressif/common-hal/countio/Counter.c | 1 + ports/espressif/common-hal/microcontroller/Processor.c | 1 + ports/espressif/common-hal/nvm/ByteArray.c | 7 ++++--- ports/espressif/common-hal/os/__init__.c | 2 ++ ports/espressif/common-hal/ps2io/Ps2.c | 1 + ports/espressif/common-hal/pulseio/PulseIn.c | 1 + ports/espressif/common-hal/pulseio/PulseOut.c | 1 + .../espressif/common-hal/rotaryio/IncrementalEncoder.c | 1 + ports/espressif/common-hal/ssl/__init__.c | 1 + ports/espressif/common-hal/watchdog/WatchDogTimer.c | 1 + ports/espressif/common-hal/wifi/__init__.c | 1 + ports/espressif/mphalport.c | 4 +++- ports/espressif/supervisor/internal_flash.c | 1 + ports/espressif/supervisor/port.c | 3 ++- ports/espressif/supervisor/usb.c | 2 +- shared-module/canio/Match.c | 1 + shared-module/canio/Message.c | 1 + 28 files changed, 38 insertions(+), 25 deletions(-) diff --git a/ports/espressif/Makefile b/ports/espressif/Makefile index 9a928b40f4..7a034c9d2a 100644 --- a/ports/espressif/Makefile +++ b/ports/espressif/Makefile @@ -150,7 +150,7 @@ endif # option to override compiler optimization level, set in boards/$(BOARD)/mpconfigboard.mk CFLAGS += $(OPTIMIZATION_FLAGS) -CFLAGS += $(INC) -Werror -Wall -std=gnu11 -Wl,--gc-sections $(BASE_CFLAGS) $(C_DEFS) $(CFLAGS_MOD) $(COPT) +CFLAGS += $(INC) -Werror -Wall -std=gnu11 -Wl,--gc-sections $(BASE_CFLAGS) $(C_DEFS) $(CFLAGS_MOD) $(COPT) -Werror=missing-prototypes ifeq ($(IDF_TARGET_ARCH),xtensa) CFLAGS += -mlongcalls diff --git a/ports/espressif/background.c b/ports/espressif/background.c index 80b60bebe3..37fe3d5be0 100644 --- a/ports/espressif/background.c +++ b/ports/espressif/background.c @@ -26,6 +26,7 @@ #include "py/runtime.h" #include "supervisor/filesystem.h" +#include "supervisor/port.h" #include "supervisor/shared/stack.h" #include "freertos/FreeRTOS.h" diff --git a/ports/espressif/bindings/espidf/__init__.c b/ports/espressif/bindings/espidf/__init__.c index 9076294d53..4f7da39540 100644 --- a/ports/espressif/bindings/espidf/__init__.c +++ b/ports/espressif/bindings/espidf/__init__.c @@ -82,15 +82,7 @@ STATIC mp_obj_t espidf_erase_nvs(void) { MP_DEFINE_CONST_FUN_OBJ_0(espidf_erase_nvs_obj, espidf_erase_nvs); -//| class IDFError(OSError): -//| """Raised for certain generic ESP IDF errors.""" -//| ... -//| -NORETURN void mp_raise_espidf_IDFError(void) { - nlr_raise(mp_obj_new_exception(&mp_type_espidf_IDFError)); -} - -void espidf_exception_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) { +STATIC void espidf_exception_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) { mp_print_kind_t k = kind & ~PRINT_EXC_SUBCLASS; bool is_subclass = kind & PRINT_EXC_SUBCLASS; if (!is_subclass && (k == PRINT_EXC)) { diff --git a/ports/espressif/cam.c b/ports/espressif/cam.c index e435993c6d..146df43a41 100644 --- a/ports/espressif/cam.c +++ b/ports/espressif/cam.c @@ -69,7 +69,7 @@ typedef struct { static cam_obj_t *cam_obj = NULL; -void IRAM_ATTR cam_isr(void *arg) { +static void IRAM_ATTR cam_isr(void *arg) { cam_event_t cam_event = {0}; BaseType_t HPTaskAwoken = pdFALSE; typeof(I2S0.int_st) int_st = I2S0.int_st; @@ -85,7 +85,7 @@ void IRAM_ATTR cam_isr(void *arg) { } } -void IRAM_ATTR cam_vsync_isr(void *arg) { +static void IRAM_ATTR cam_vsync_isr(void *arg) { cam_event_t cam_event = {0}; BaseType_t HPTaskAwoken = pdFALSE; /*!< filter */ @@ -392,7 +392,7 @@ void cam_give(uint8_t *buffer) { } } -void cam_dma_config(const cam_config_t *config) { +static void cam_dma_config(const cam_config_t *config) { int cnt = 0; if (config->mode.jpeg) { diff --git a/ports/espressif/common-hal/alarm/SleepMemory.c b/ports/espressif/common-hal/alarm/SleepMemory.c index b25bf28d25..764125ddb2 100644 --- a/ports/espressif/common-hal/alarm/SleepMemory.c +++ b/ports/espressif/common-hal/alarm/SleepMemory.c @@ -29,6 +29,7 @@ #include "py/runtime.h" #include "common-hal/alarm/SleepMemory.h" +#include "shared-bindings/alarm/SleepMemory.h" #include "esp_log.h" #include "esp_sleep.h" diff --git a/ports/espressif/common-hal/alarm/pin/PinAlarm.c b/ports/espressif/common-hal/alarm/pin/PinAlarm.c index 970094783e..754902f678 100644 --- a/ports/espressif/common-hal/alarm/pin/PinAlarm.c +++ b/ports/espressif/common-hal/alarm/pin/PinAlarm.c @@ -72,7 +72,7 @@ gpio_isr_handle_t gpio_interrupt_handle; // Low and high are relative to pin number. 32+ is high. <32 is low. static volatile uint32_t pin_31_0_status = 0; static volatile uint32_t pin_63_32_status = 0; -void gpio_interrupt(void *arg) { +STATIC void gpio_interrupt(void *arg) { (void)arg; gpio_ll_get_intr_status(&GPIO, xPortGetCoreID(), (uint32_t *)&pin_31_0_status); diff --git a/ports/espressif/common-hal/alarm/time/TimeAlarm.c b/ports/espressif/common-hal/alarm/time/TimeAlarm.c index 0fb29a3ed4..256d96a75f 100644 --- a/ports/espressif/common-hal/alarm/time/TimeAlarm.c +++ b/ports/espressif/common-hal/alarm/time/TimeAlarm.c @@ -63,7 +63,7 @@ esp_timer_handle_t pretend_sleep_timer; STATIC bool woke_up = false; // This is run in the timer task. We use it to wake the main CircuitPython task. -void timer_callback(void *arg) { +STATIC void timer_callback(void *arg) { (void)arg; woke_up = true; xTaskNotifyGive(circuitpython_task); diff --git a/ports/espressif/common-hal/alarm/touch/TouchAlarm.c b/ports/espressif/common-hal/alarm/touch/TouchAlarm.c index e005999ee5..6ae2421e4c 100644 --- a/ports/espressif/common-hal/alarm/touch/TouchAlarm.c +++ b/ports/espressif/common-hal/alarm/touch/TouchAlarm.c @@ -75,7 +75,7 @@ mp_obj_t alarm_touch_touchalarm_create_wakeup_alarm(void) { } // This is used to wake the main CircuitPython task. -void touch_interrupt(void *arg) { +STATIC void touch_interrupt(void *arg) { (void)arg; woke_up = true; BaseType_t task_wakeup; diff --git a/ports/espressif/common-hal/analogio/AnalogIn.c b/ports/espressif/common-hal/analogio/AnalogIn.c index add4c3e14e..df39b30c63 100644 --- a/ports/espressif/common-hal/analogio/AnalogIn.c +++ b/ports/espressif/common-hal/analogio/AnalogIn.c @@ -25,6 +25,7 @@ */ #include "common-hal/analogio/AnalogIn.h" +#include "shared-bindings/analogio/AnalogIn.h" #include "py/mperrno.h" #include "py/runtime.h" #include "supervisor/shared/translate.h" diff --git a/ports/espressif/common-hal/canio/CAN.c b/ports/espressif/common-hal/canio/CAN.c index 720034755b..eebf064f44 100644 --- a/ports/espressif/common-hal/canio/CAN.c +++ b/ports/espressif/common-hal/canio/CAN.c @@ -38,7 +38,7 @@ STATIC bool reserved_can; -twai_timing_config_t get_t_config(int baudrate) { +STATIC twai_timing_config_t get_t_config(int baudrate) { switch (baudrate) { case 1000000: { // TWAI_TIMING_CONFIG_abc expands to a C designated initializer list @@ -204,7 +204,7 @@ static void can_restart(void) { } while (port_get_raw_ticks(NULL) < deadline && (info.state == TWAI_STATE_BUS_OFF || info.state == TWAI_STATE_RECOVERING)); } -void canio_maybe_auto_restart(canio_can_obj_t *self) { +STATIC void canio_maybe_auto_restart(canio_can_obj_t *self) { if (self->auto_restart) { can_restart(); } diff --git a/ports/espressif/common-hal/canio/Listener.c b/ports/espressif/common-hal/canio/Listener.c index 8100261743..eccddf6243 100644 --- a/ports/espressif/common-hal/canio/Listener.c +++ b/ports/espressif/common-hal/canio/Listener.c @@ -78,7 +78,7 @@ STATIC void install_all_match_filter(canio_listener_obj_t *self) { } __attribute__((noinline,optimize("O0"))) -void set_filters(canio_listener_obj_t *self, size_t nmatch, canio_match_obj_t **matches) { +STATIC void set_filters(canio_listener_obj_t *self, size_t nmatch, canio_match_obj_t **matches) { twai_ll_enter_reset_mode(&TWAI); if (!nmatch) { diff --git a/ports/espressif/common-hal/countio/Counter.c b/ports/espressif/common-hal/countio/Counter.c index bdc8b290fe..418a8ae4d4 100644 --- a/ports/espressif/common-hal/countio/Counter.c +++ b/ports/espressif/common-hal/countio/Counter.c @@ -25,6 +25,7 @@ */ #include "common-hal/countio/Counter.h" +#include "shared-bindings/countio/Counter.h" #include "common-hal/microcontroller/Pin.h" #include "py/runtime.h" diff --git a/ports/espressif/common-hal/microcontroller/Processor.c b/ports/espressif/common-hal/microcontroller/Processor.c index 5f956b4412..c50c6fbf7a 100644 --- a/ports/espressif/common-hal/microcontroller/Processor.c +++ b/ports/espressif/common-hal/microcontroller/Processor.c @@ -31,6 +31,7 @@ #include "py/runtime.h" #include "common-hal/microcontroller/Processor.h" +#include "shared-bindings/microcontroller/Processor.h" #include "shared-bindings/microcontroller/ResetReason.h" #include "supervisor/shared/translate.h" diff --git a/ports/espressif/common-hal/nvm/ByteArray.c b/ports/espressif/common-hal/nvm/ByteArray.c index 6eeed72e2e..a17e368249 100644 --- a/ports/espressif/common-hal/nvm/ByteArray.c +++ b/ports/espressif/common-hal/nvm/ByteArray.c @@ -27,13 +27,14 @@ #include #include "common-hal/nvm/ByteArray.h" +#include "shared-bindings/nvm/ByteArray.h" #include "bindings/espidf/__init__.h" #include "py/runtime.h" #include "py/gc.h" #include "nvs_flash.h" -uint32_t common_hal_nvm_bytearray_get_length(nvm_bytearray_obj_t *self) { +uint32_t common_hal_nvm_bytearray_get_length(const nvm_bytearray_obj_t *self) { return self->len; } @@ -75,7 +76,7 @@ static esp_err_t get_bytes(nvs_handle_t handle, uint8_t **buf_out) { return result; } -bool common_hal_nvm_bytearray_set_bytes(nvm_bytearray_obj_t *self, +bool common_hal_nvm_bytearray_set_bytes(const nvm_bytearray_obj_t *self, uint32_t start_index, uint8_t *values, uint32_t len) { // start nvs @@ -122,7 +123,7 @@ bool common_hal_nvm_bytearray_set_bytes(nvm_bytearray_obj_t *self, return true; } -void common_hal_nvm_bytearray_get_bytes(nvm_bytearray_obj_t *self, +void common_hal_nvm_bytearray_get_bytes(const nvm_bytearray_obj_t *self, uint32_t start_index, uint32_t len, uint8_t *values) { // start nvs diff --git a/ports/espressif/common-hal/os/__init__.c b/ports/espressif/common-hal/os/__init__.c index b77898016f..1dcd3e46e0 100644 --- a/ports/espressif/common-hal/os/__init__.c +++ b/ports/espressif/common-hal/os/__init__.c @@ -30,6 +30,8 @@ #include "py/objtuple.h" #include "py/qstr.h" +#include "shared-bindings/os/__init__.h" + #include "esp_system.h" STATIC const qstr os_uname_info_fields[] = { diff --git a/ports/espressif/common-hal/ps2io/Ps2.c b/ports/espressif/common-hal/ps2io/Ps2.c index f4845b0fa8..2b6dc52967 100644 --- a/ports/espressif/common-hal/ps2io/Ps2.c +++ b/ports/espressif/common-hal/ps2io/Ps2.c @@ -25,6 +25,7 @@ */ #include "common-hal/ps2io/Ps2.h" +#include "shared-bindings/ps2io/Ps2.h" #include "supervisor/port.h" #include "shared-bindings/microcontroller/__init__.h" diff --git a/ports/espressif/common-hal/pulseio/PulseIn.c b/ports/espressif/common-hal/pulseio/PulseIn.c index 4b314e2f8d..3f5457f84b 100644 --- a/ports/espressif/common-hal/pulseio/PulseIn.c +++ b/ports/espressif/common-hal/pulseio/PulseIn.c @@ -25,6 +25,7 @@ */ #include "common-hal/pulseio/PulseIn.h" +#include "shared-bindings/pulseio/PulseIn.h" #include "shared-bindings/microcontroller/__init__.h" #include "py/runtime.h" diff --git a/ports/espressif/common-hal/pulseio/PulseOut.c b/ports/espressif/common-hal/pulseio/PulseOut.c index 1cb02089e7..993fd9452c 100644 --- a/ports/espressif/common-hal/pulseio/PulseOut.c +++ b/ports/espressif/common-hal/pulseio/PulseOut.c @@ -25,6 +25,7 @@ */ #include "common-hal/pulseio/PulseOut.h" +#include "shared-bindings/pulseio/PulseOut.h" #include "shared-bindings/pwmio/PWMOut.h" #include "py/runtime.h" diff --git a/ports/espressif/common-hal/rotaryio/IncrementalEncoder.c b/ports/espressif/common-hal/rotaryio/IncrementalEncoder.c index b36c79b4f6..676e99289d 100644 --- a/ports/espressif/common-hal/rotaryio/IncrementalEncoder.c +++ b/ports/espressif/common-hal/rotaryio/IncrementalEncoder.c @@ -25,6 +25,7 @@ */ #include "common-hal/rotaryio/IncrementalEncoder.h" +#include "shared-bindings/rotaryio/IncrementalEncoder.h" #include "common-hal/microcontroller/Pin.h" #include "py/runtime.h" diff --git a/ports/espressif/common-hal/ssl/__init__.c b/ports/espressif/common-hal/ssl/__init__.c index a0886adda7..61ea32f395 100644 --- a/ports/espressif/common-hal/ssl/__init__.c +++ b/ports/espressif/common-hal/ssl/__init__.c @@ -24,6 +24,7 @@ * THE SOFTWARE. */ +#include "shared-bindings/ssl/__init__.h" #include "shared-bindings/ssl/SSLContext.h" #include "components/mbedtls/esp_crt_bundle/include/esp_crt_bundle.h" diff --git a/ports/espressif/common-hal/watchdog/WatchDogTimer.c b/ports/espressif/common-hal/watchdog/WatchDogTimer.c index 729ab5815a..159c99458f 100644 --- a/ports/espressif/common-hal/watchdog/WatchDogTimer.c +++ b/ports/espressif/common-hal/watchdog/WatchDogTimer.c @@ -32,6 +32,7 @@ #include "esp_task_wdt.h" +extern void esp_task_wdt_isr_user_handler(void); void esp_task_wdt_isr_user_handler(void) { mp_obj_exception_clear_traceback(MP_OBJ_FROM_PTR(&mp_watchdog_timeout_exception)); MP_STATE_THREAD(mp_pending_exception) = &mp_watchdog_timeout_exception; diff --git a/ports/espressif/common-hal/wifi/__init__.c b/ports/espressif/common-hal/wifi/__init__.c index 8d19a91cb2..a39103ce0a 100644 --- a/ports/espressif/common-hal/wifi/__init__.c +++ b/ports/espressif/common-hal/wifi/__init__.c @@ -25,6 +25,7 @@ */ #include "common-hal/wifi/__init__.h" +#include "shared-bindings/wifi/__init__.h" #include "shared-bindings/ipaddress/IPv4Address.h" #include "shared-bindings/wifi/Radio.h" diff --git a/ports/espressif/mphalport.c b/ports/espressif/mphalport.c index 632e18039a..f22856f0a4 100644 --- a/ports/espressif/mphalport.c +++ b/ports/espressif/mphalport.c @@ -39,6 +39,8 @@ #include "components/esp_rom/include/esp32s2/rom/ets_sys.h" #endif +#include "supervisor/cpu.h" + void mp_hal_delay_us(mp_uint_t delay) { ets_delay_us(delay); } @@ -48,7 +50,7 @@ void mp_hal_delay_us(mp_uint_t delay) { extern void xthal_window_spill(void); #endif -mp_uint_t cpu_get_regs_and_sp(mp_uint_t *regs, uint8_t reg_count) { +mp_uint_t cpu_get_regs_and_sp(mp_uint_t *regs) { // xtensa has more registers than an instruction can address. The 16 that // can be addressed are called the "window". When a function is called or // returns the window rotates. This allows for more efficient function calls diff --git a/ports/espressif/supervisor/internal_flash.c b/ports/espressif/supervisor/internal_flash.c index 8f3d917765..2f17b48f0c 100644 --- a/ports/espressif/supervisor/internal_flash.c +++ b/ports/espressif/supervisor/internal_flash.c @@ -39,6 +39,7 @@ #include "components/spi_flash/include/esp_partition.h" +#include "supervisor/flash.h" #include "supervisor/usb.h" STATIC const esp_partition_t *_partition; diff --git a/ports/espressif/supervisor/port.c b/ports/espressif/supervisor/port.c index 7425bb615e..30106075e7 100644 --- a/ports/espressif/supervisor/port.c +++ b/ports/espressif/supervisor/port.c @@ -93,7 +93,7 @@ TaskHandle_t circuitpython_task = NULL; extern void esp_restart(void) NORETURN; -void tick_timer_cb(void *arg) { +STATIC void tick_timer_cb(void *arg) { supervisor_tick(); // CircuitPython's VM is run in a separate FreeRTOS task from timer callbacks. So, we have to @@ -360,6 +360,7 @@ void port_idle_until_interrupt(void) { // Wrap main in app_main that the IDF expects. extern void main(void); +extern void app_main(void); void app_main(void) { main(); } diff --git a/ports/espressif/supervisor/usb.c b/ports/espressif/supervisor/usb.c index fa9d09fa44..2137a7b0a4 100644 --- a/ports/espressif/supervisor/usb.c +++ b/ports/espressif/supervisor/usb.c @@ -62,7 +62,7 @@ StaticTask_t usb_device_taskdef; // USB Device Driver task // This top level thread process all usb events and invoke callbacks -void usb_device_task(void *param) { +STATIC void usb_device_task(void *param) { (void)param; // RTOS forever loop diff --git a/shared-module/canio/Match.c b/shared-module/canio/Match.c index b4e8616e9b..ae8fd40893 100644 --- a/shared-module/canio/Match.c +++ b/shared-module/canio/Match.c @@ -25,6 +25,7 @@ */ #include "shared-module/canio/Match.h" +#include "shared-bindings/canio/Match.h" void common_hal_canio_match_construct(canio_match_obj_t *self, int id, int mask, bool extended) { self->id = id; diff --git a/shared-module/canio/Message.c b/shared-module/canio/Message.c index 08e4d9fda7..7c0dcf739a 100644 --- a/shared-module/canio/Message.c +++ b/shared-module/canio/Message.c @@ -25,6 +25,7 @@ */ #include "shared-module/canio/Message.h" +#include "shared-bindings/canio/Message.h" #include