diff --git a/components/audio_sal/include/audio_sys.h b/components/audio_sal/include/audio_sys.h index fc6435017..715557632 100644 --- a/components/audio_sal/include/audio_sys.h +++ b/components/audio_sal/include/audio_sys.h @@ -34,6 +34,12 @@ extern "C" { #define ___STR___(x) #x #define STR_AUDIO(x) ___STR___(x) +#if defined(__GNUC__) && __GNUC__ >= 7 + #define FALL_THROUGH __attribute__ ((fallthrough)) +#else + #define FALL_THROUGH ((void)0) +#endif /* __GNUC__ >= 7 */ + /** * @brief Get system ticks by given millisecond * diff --git a/components/battery_service/battery_service.c b/components/battery_service/battery_service.c index da95a7a89..222433ae2 100644 --- a/components/battery_service/battery_service.c +++ b/components/battery_service/battery_service.c @@ -31,6 +31,7 @@ #include "esp_log.h" #include "audio_mem.h" +#include "audio_sys.h" #include "battery_service.h" typedef struct battery_service { @@ -120,7 +121,7 @@ static void battery_task(void *pvParameters) } case BATTERY_SERVICE_DESTROY: service->running = false; - __attribute__((fallthrough)); + FALL_THROUGH; // No break, to share the actions of case `BATTERY_SERVICE_STOP`, clear all the monitors. case BATTERY_SERVICE_STOP: { if (service->vol_monitor != NULL) { diff --git a/components/ota_service/esp_fs_ota.c b/components/ota_service/esp_fs_ota.c index 288bdd77e..173fc81cf 100644 --- a/components/ota_service/esp_fs_ota.c +++ b/components/ota_service/esp_fs_ota.c @@ -30,6 +30,7 @@ #include #include #include "audio_mem.h" +#include "audio_sys.h" #define IMAGE_HEADER_SIZE (sizeof(esp_image_header_t) + sizeof(esp_image_segment_header_t) + sizeof(esp_app_desc_t) + 1) #define DEFAULT_OTA_BUF_SIZE IMAGE_HEADER_SIZE @@ -232,7 +233,7 @@ esp_err_t esp_fs_ota_finish(esp_fs_ota_handle_t fs_ota_handle) case ESP_FS_OTA_SUCCESS: case ESP_FS_OTA_IN_PROGRESS: err = esp_ota_end(handle->update_handle); - __attribute__((fallthrough)); + FALL_THROUGH; case ESP_FS_OTA_BEGIN: if (handle->ota_upgrade_buf) { audio_free(handle->ota_upgrade_buf); diff --git a/examples/cli/main/console_example.c b/examples/cli/main/console_example.c index 6005efe8c..d52c56809 100644 --- a/examples/cli/main/console_example.c +++ b/examples/cli/main/console_example.c @@ -284,6 +284,7 @@ static esp_err_t wifi_set(esp_periph_handle_t periph, int argc, char *argv[]) switch (argc) { case 2: memcpy(w_config.sta.password, argv[1], sizeof(w_config.sta.password)); + FALL_THROUGH; case 1: memcpy(w_config.sta.ssid, argv[0], sizeof(w_config.sta.ssid)); esp_wifi_disconnect();