Skip to content

Commit

Permalink
Fix __attribute__ ((fallthrough)) is valid in GCC7
Browse files Browse the repository at this point in the history
  • Loading branch information
jason-mao committed Aug 13, 2021
1 parent fea3167 commit d6273b8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
6 changes: 6 additions & 0 deletions components/audio_sal/include/audio_sys.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
3 changes: 2 additions & 1 deletion components/battery_service/battery_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

#include "esp_log.h"
#include "audio_mem.h"
#include "audio_sys.h"
#include "battery_service.h"

typedef struct battery_service {
Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion components/ota_service/esp_fs_ota.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <esp_ota_ops.h>
#include <errno.h>
#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
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions examples/cli/main/console_example.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit d6273b8

Please sign in to comment.