diff options
53 files changed, 86 insertions, 44 deletions
diff --git a/Makefile.toolchain b/Makefile.toolchain index 3c93d774d4..c2612d260c 100644 --- a/Makefile.toolchain +++ b/Makefile.toolchain @@ -115,7 +115,7 @@ C_WARN = -Wstrict-prototypes -Wdeclaration-after-statement -Wno-pointer-sign C_WARN += -Werror-implicit-function-declaration COMMON_WARN = -Wall -Wundef \ -Wno-trigraphs -Wno-format-security -Wno-address-of-packed-member \ - -fno-common -fno-strict-aliasing -fno-strict-overflow + -fno-common -fno-strict-aliasing -fno-strict-overflow -Wimplicit-fallthrough # See https://www.chromium.org/chromium-os/build/c-exception-support COMMON_WARN+=-fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables diff --git a/baseboard/intelrvp/led_states.c b/baseboard/intelrvp/led_states.c index 8629085c4f..6bcee159a3 100644 --- a/baseboard/intelrvp/led_states.c +++ b/baseboard/intelrvp/led_states.c @@ -39,7 +39,7 @@ static enum led_states led_get_state(void) new_state = STATE_CHARGING_FULL_CHARGE; break; } - /* Intentional fall-through */ + __fallthrough; case PWR_STATE_DISCHARGE /* and PWR_STATE_DISCHARGE_FULL */: if (chipset_in_state(CHIPSET_STATE_ON)) new_state = STATE_DISCHARGE_S0; diff --git a/board/boldar/board.c b/board/boldar/board.c index 19b8f44020..1076ccc040 100644 --- a/board/boldar/board.c +++ b/board/boldar/board.c @@ -474,6 +474,7 @@ void ppc_interrupt(enum gpio_signal signal) break; case GPIO_USB_C1_PPC_INT_ODL: syv682x_interrupt(USBC_PORT_C1); + break; default: break; } diff --git a/board/burnet/led.c b/board/burnet/led.c index 4aa91c63e2..68c4c9e839 100644 --- a/board/burnet/led.c +++ b/board/burnet/led.c @@ -147,7 +147,7 @@ static void led_set_battery(void) led_set_color_battery(LED_WHITE); break; } - /* Intentional fall-through */ + __fallthrough; case PWR_STATE_DISCHARGE: /* * Blink white light (1 sec on, 1 sec off) diff --git a/board/careena/led.c b/board/careena/led.c index 48a065fdb9..9a280a011b 100644 --- a/board/careena/led.c +++ b/board/careena/led.c @@ -110,7 +110,7 @@ static void led_set_battery(void) led_set_color_battery(LED_WHITE); break; } - /* Intentional fall-through */ + __fallthrough; case PWR_STATE_DISCHARGE: /* * Blink white light (1 sec on, 1 sec off) diff --git a/board/chronicler/usbc_config.c b/board/chronicler/usbc_config.c index b05cd4ecfd..85c40e93e1 100644 --- a/board/chronicler/usbc_config.c +++ b/board/chronicler/usbc_config.c @@ -68,6 +68,7 @@ void ppc_interrupt(enum gpio_signal signal) break; case GPIO_USB_C1_PPC_INT_ODL: syv682x_interrupt(USBC_PORT_C1); + break; default: break; } diff --git a/board/collis/board.c b/board/collis/board.c index 6b2c81bc02..56c67989a5 100644 --- a/board/collis/board.c +++ b/board/collis/board.c @@ -270,6 +270,7 @@ void ppc_interrupt(enum gpio_signal signal) break; case GPIO_USB_C1_PPC_INT_ODL: syv682x_interrupt(USBC_PORT_C1); + break; default: break; } diff --git a/board/copano/board.c b/board/copano/board.c index b4a8c5eb20..8d58fa1101 100644 --- a/board/copano/board.c +++ b/board/copano/board.c @@ -310,6 +310,7 @@ void ppc_interrupt(enum gpio_signal signal) break; case GPIO_USB_C1_PPC_INT_ODL: syv682x_interrupt(USBC_PORT_C1); + break; default: break; } diff --git a/board/coral/led.c b/board/coral/led.c index 8af0f6f3e2..b8515c14c7 100644 --- a/board/coral/led.c +++ b/board/coral/led.c @@ -188,7 +188,7 @@ static enum led_states led_get_state(void) new_state = STATE_CHARGING_LVL_3; break; } - /* Intentional fall-through */ + __fallthrough; case PWR_STATE_DISCHARGE /* and PWR_STATE_DISCHARGE_FULL */: if (chipset_in_state(CHIPSET_STATE_ON)) new_state = STATE_DISCHARGE_S0; diff --git a/board/corori/led.c b/board/corori/led.c index 89799c8e74..f47871a4ed 100644 --- a/board/corori/led.c +++ b/board/corori/led.c @@ -127,7 +127,7 @@ static enum led_states led_get_state(void) new_state = STATE_CHARGING_FULL_CHARGE; break; } - /* Intentional fall-through */ + __fallthrough; case PWR_STATE_DISCHARGE /* and PWR_STATE_DISCHARGE_FULL */: if (chipset_in_state(CHIPSET_STATE_ON)) new_state = (led_get_charge_percent() < 10) ? diff --git a/board/delbin/board.c b/board/delbin/board.c index 1cdb42d954..28a0c929e2 100644 --- a/board/delbin/board.c +++ b/board/delbin/board.c @@ -370,6 +370,7 @@ void ppc_interrupt(enum gpio_signal signal) break; case GPIO_USB_C1_PPC_INT_ODL: syv682x_interrupt(USBC_PORT_C1); + break; default: break; } diff --git a/board/drawcia/led.c b/board/drawcia/led.c index 8e6263fbbc..0fee248506 100644 --- a/board/drawcia/led.c +++ b/board/drawcia/led.c @@ -142,7 +142,7 @@ static void led_set_battery(void) led_set_color_battery(LED_WHITE); break; } - /* Intentional fall-through */ + __fallthrough; case PWR_STATE_DISCHARGE: /* * Blink white light (1 sec on, 1 sec off) diff --git a/board/drawcia_riscv/led.c b/board/drawcia_riscv/led.c index 3cb7cb835e..d72626b2a2 100644 --- a/board/drawcia_riscv/led.c +++ b/board/drawcia_riscv/led.c @@ -142,7 +142,7 @@ static void led_set_battery(void) led_set_color_battery(LED_WHITE); break; } - /* Intentional fall-through */ + __fallthrough; case PWR_STATE_DISCHARGE: /* * Blink white light (1 sec on, 1 sec off) diff --git a/board/drobit/board.c b/board/drobit/board.c index 19b5162092..1a20870d1f 100644 --- a/board/drobit/board.c +++ b/board/drobit/board.c @@ -303,6 +303,7 @@ void ppc_interrupt(enum gpio_signal signal) break; case GPIO_USB_C1_PPC_INT_ODL: syv682x_interrupt(USBC_PORT_C1); + break; default: break; } diff --git a/board/eldrid/board.c b/board/eldrid/board.c index 717878bc95..81fdf22ffc 100644 --- a/board/eldrid/board.c +++ b/board/eldrid/board.c @@ -516,6 +516,7 @@ void ppc_interrupt(enum gpio_signal signal) break; case GPIO_USB_C1_PPC_INT_ODL: syv682x_interrupt(USBC_PORT_C1); + break; default: break; } diff --git a/board/elemi/board.c b/board/elemi/board.c index 6b166e1206..96860d2335 100644 --- a/board/elemi/board.c +++ b/board/elemi/board.c @@ -347,6 +347,7 @@ void ppc_interrupt(enum gpio_signal signal) break; case GPIO_USB_C1_PPC_INT_ODL: syv682x_interrupt(USBC_PORT_C1); + break; default: break; } diff --git a/board/haboki/led.c b/board/haboki/led.c index b31d4fab75..c6e481e285 100644 --- a/board/haboki/led.c +++ b/board/haboki/led.c @@ -142,7 +142,7 @@ static void led_set_battery(void) led_set_color_battery(LED_WHITE); break; } - /* Intentional fall-through */ + __fallthrough; case PWR_STATE_DISCHARGE: /* * Blink white light (1 sec on, 1 sec off) diff --git a/board/kappa/led.c b/board/kappa/led.c index 1c7979eac0..1dc86013d7 100644 --- a/board/kappa/led.c +++ b/board/kappa/led.c @@ -104,7 +104,7 @@ static void led_set_battery(void) led_set_color_battery(LED_WHITE); break; } - /* Intentional fall-through */ + __fallthrough; case PWR_STATE_DISCHARGE: /* * Blink white light (1 sec on, 1 sec off) diff --git a/board/lantis/led.c b/board/lantis/led.c index d6dbc929a8..3b66ad6d6b 100644 --- a/board/lantis/led.c +++ b/board/lantis/led.c @@ -199,7 +199,7 @@ static void led_set_battery(void) set_active_port_color(LED_WHITE); break; } - /* Intentional fall-through */ + __fallthrough; case PWR_STATE_DISCHARGE: /* * Blink white/amber light (1 sec on, 1 sec off) diff --git a/board/lindar/board.c b/board/lindar/board.c index 5bb155550e..e3ee0ff9c4 100644 --- a/board/lindar/board.c +++ b/board/lindar/board.c @@ -479,6 +479,7 @@ void ppc_interrupt(enum gpio_signal signal) break; case GPIO_USB_C1_PPC_INT_ODL: syv682x_interrupt(USBC_PORT_C1); + break; default: break; } diff --git a/board/reef/led.c b/board/reef/led.c index 95db062d10..8bc52dbc75 100644 --- a/board/reef/led.c +++ b/board/reef/led.c @@ -104,7 +104,7 @@ static void led_set_battery(void) led_set_color_battery(LED_BLUE); break; } - /* Intentional fall-through */ + __fallthrough; case PWR_STATE_DISCHARGE /* and PWR_STATE_DISCHARGE_FULL */: if (chipset_in_state(CHIPSET_STATE_ON)) { led_set_color_battery(LED_BLUE); diff --git a/board/reef_it8320/led.c b/board/reef_it8320/led.c index 1b521b9409..630fdf336d 100644 --- a/board/reef_it8320/led.c +++ b/board/reef_it8320/led.c @@ -105,7 +105,7 @@ static void led_set_battery(void) led_set_color_battery(LED_BLUE); break; } - /* Intentional fall-through */ + __fallthrough; case PWR_STATE_DISCHARGE /* and PWR_STATE_DISCHARGE_FULL */: if (chipset_in_state(CHIPSET_STATE_ON)) { led_set_color_battery(LED_BLUE); diff --git a/board/reef_mchp/led.c b/board/reef_mchp/led.c index 469758dc26..96ea6bb958 100644 --- a/board/reef_mchp/led.c +++ b/board/reef_mchp/led.c @@ -105,7 +105,7 @@ static void led_set_battery(void) led_set_color_battery(LED_BLUE); break; } - /* Intentional fall-through */ + __fallthrough; case PWR_STATE_DISCHARGE /* and PWR_STATE_DISCHARGE_FULL */: if (chipset_in_state(CHIPSET_STATE_ON)) { led_set_color_battery(LED_BLUE); diff --git a/board/voema/board.c b/board/voema/board.c index c4563df105..363cc603ad 100644 --- a/board/voema/board.c +++ b/board/voema/board.c @@ -309,6 +309,7 @@ void ppc_interrupt(enum gpio_signal signal) break; case GPIO_USB_C1_PPC_INT_ODL: syv682x_interrupt(USBC_PORT_C1); + break; default: break; } diff --git a/board/volet/board.c b/board/volet/board.c index 474ec9cb0e..47140464b6 100644 --- a/board/volet/board.c +++ b/board/volet/board.c @@ -369,6 +369,7 @@ void ppc_interrupt(enum gpio_signal signal) break; case GPIO_USB_C1_PPC_INT_ODL: syv682x_interrupt(USBC_PORT_C1); + break; default: break; } diff --git a/board/voxel/board.c b/board/voxel/board.c index 40dfbe8dc4..4c8badeb1c 100644 --- a/board/voxel/board.c +++ b/board/voxel/board.c @@ -367,6 +367,7 @@ void ppc_interrupt(enum gpio_signal signal) break; case GPIO_USB_C1_PPC_INT_ODL: syv682x_interrupt(USBC_PORT_C1); + break; default: break; } diff --git a/chip/npcx/system.c b/chip/npcx/system.c index 958d873401..9ce043354f 100644 --- a/chip/npcx/system.c +++ b/chip/npcx/system.c @@ -1410,6 +1410,7 @@ void system_set_image_copy(enum ec_image copy) "Change it to %d.", copy, EC_IMAGE_RO); /* Fall through to EC_IMAGE_RO */ + __fallthrough; case EC_IMAGE_RO: SET_BIT(NPCX_FWCTRL, NPCX_FWCTRL_RO_REGION); SET_BIT(NPCX_FWCTRL, NPCX_FWCTRL_FW_SLOT); diff --git a/chip/npcx/wov.c b/chip/npcx/wov.c index 1ae1afe71d..8616cdd001 100644 --- a/chip/npcx/wov.c +++ b/chip/npcx/wov.c @@ -836,6 +836,7 @@ enum ec_error_list wov_set_mode(enum wov_modes wov_mode) case WOV_MODE_RAM_AND_I2S: if ((wov_conf.bit_depth != 16) && (wov_conf.bit_depth != 24)) return EC_ERROR_INVAL; + __fallthrough; case WOV_MODE_I2S: if (apm_get_adc_i2s_dmic_rate() == APM_DMIC_RATE_0_75) wov_dmic_clk_config(1, WOV_DMIC_DIV_BY_4); diff --git a/common/charge_ramp_sw.c b/common/charge_ramp_sw.c index 4c09a94a8d..4e5bdc8149 100644 --- a/common/charge_ramp_sw.c +++ b/common/charge_ramp_sw.c @@ -214,6 +214,7 @@ void chg_ramp_task(void *u) ramp_st_new = CHG_RAMP_OVERCURRENT_DETECT; /* notify host of power info change */ pd_send_host_event(PD_EVENT_POWER_CHANGE); + __fallthrough; case CHG_RAMP_OVERCURRENT_DETECT: /* Check if we should ramp or go straight to stable */ task_wait_time = SECOND; diff --git a/common/console.c b/common/console.c index 9e7d6ad036..b045af1ddf 100644 --- a/common/console.c +++ b/common/console.c @@ -507,6 +507,7 @@ static void console_handle_char(int c) move_cursor_right(); /* Drop through to backspace handling */ + __fallthrough; case '\b': case 0x7f: handle_backspace(); diff --git a/common/led_onoff_states.c b/common/led_onoff_states.c index 244257cf1d..404ae06cd9 100644 --- a/common/led_onoff_states.c +++ b/common/led_onoff_states.c @@ -71,7 +71,7 @@ static enum led_states led_get_state(void) new_state = STATE_CHARGING_FULL_CHARGE; break; } - /* Intentional fall-through */ + __fallthrough; case PWR_STATE_DISCHARGE /* and PWR_STATE_DISCHARGE_FULL */: if (chipset_in_state(CHIPSET_STATE_ON)) { #ifdef CONFIG_LED_ONOFF_STATES_BAT_LOW diff --git a/common/motion_sense.c b/common/motion_sense.c index f326259497..38bc5ab702 100644 --- a/common/motion_sense.c +++ b/common/motion_sense.c @@ -1320,7 +1320,7 @@ static enum ec_status host_cmd_motion_sense(struct host_cmd_handler_args *args) task_set_event(TASK_ID_MOTIONSENSE, TASK_EVENT_MOTION_FLUSH_PENDING); - /* pass-through */ + __fallthrough; case MOTIONSENSE_CMD_FIFO_INFO: if (!IS_ENABLED(CONFIG_ACCEL_FIFO)) { /* @@ -1352,7 +1352,7 @@ static enum ec_status host_cmd_motion_sense(struct host_cmd_handler_args *args) case 0: case 1: fifo_int_enabled = in->fifo_int_enable.enable; - /* fallthrough */ + __fallthrough; case EC_MOTION_SENSE_NO_VALUE: out->fifo_int_enable.ret = fifo_int_enabled; args->response_size = sizeof(out->fifo_int_enable); diff --git a/common/system.c b/common/system.c index c3a0f8ac58..6f64960170 100644 --- a/common/system.c +++ b/common/system.c @@ -1020,7 +1020,7 @@ static int handle_pending_reboot(enum ec_reboot_cmd cmd) chip_save_reset_flags(chip_read_reset_flags() & ~EC_RESET_FLAG_AP_IDLE); } - /* Intentional fall-through */ + __fallthrough; case EC_REBOOT_HIBERNATE: if (!IS_ENABLED(CONFIG_HIBERNATE)) return EC_ERROR_INVAL; diff --git a/common/usb_port_power_dumb.c b/common/usb_port_power_dumb.c index 10eca3ffb7..cfdc016662 100644 --- a/common/usb_port_power_dumb.c +++ b/common/usb_port_power_dumb.c @@ -104,7 +104,7 @@ static int command_set_mode(int argc, const char **argv) return EC_ERROR_PARAM2; usb_port_set_enabled(port_id, mode); - /* fallthrough */ + __fallthrough; case 1: for (i = 0; i < USB_PORT_COUNT; i++) ccprintf("Port %d: %s\n", i, diff --git a/common/usbc/dp_alt_mode.c b/common/usbc/dp_alt_mode.c index 0f2a42ec2a..f53d212b91 100644 --- a/common/usbc/dp_alt_mode.c +++ b/common/usbc/dp_alt_mode.c @@ -283,6 +283,7 @@ enum dpm_msg_setup_status dp_setup_next_vdm(int port, int *vdo_count, return MSG_SETUP_MUX_WAIT; } /* Fall through if no mux set is needed */ + __fallthrough; case DP_PREPARE_CONFIG: vdo_count_ret = modep->fx->config(port, vdm); if (vdo_count_ret == 0) @@ -293,6 +294,7 @@ enum dpm_msg_setup_status dp_setup_next_vdm(int port, int *vdo_count, case DP_ENTER_NAKED: DP_SET_FLAG(port, DP_FLAG_RETRY); /* Fall through to send exit mode */ + __fallthrough; case DP_ACTIVE: /* * Called to exit DP alt mode, either when the mode diff --git a/common/usbc/tbt_alt_mode.c b/common/usbc/tbt_alt_mode.c index d1ad031fad..c0e4e172cc 100644 --- a/common/usbc/tbt_alt_mode.c +++ b/common/usbc/tbt_alt_mode.c @@ -514,7 +514,7 @@ enum dpm_msg_setup_status tbt_setup_next_vdm(int port, int *vdo_count, * done with any retires. */ TBT_SET_FLAG(port, TBT_FLAG_RETRY_DONE); - /* Fall through */ + __fallthrough; case TBT_PREPARE_EXIT_MODE: /* * Called to exit Thunderbolt alt mode, either when the mode is diff --git a/common/usbc/usb_pd_dpm.c b/common/usbc/usb_pd_dpm.c index 3af3ac3dbe..2538ef0be6 100644 --- a/common/usbc/usb_pd_dpm.c +++ b/common/usbc/usb_pd_dpm.c @@ -243,6 +243,7 @@ void dpm_vdm_acked(int port, enum tcpci_msg_type type, int vdo_count, intel_vdm_acked(port, type, vdo_count, vdm); break; } + __fallthrough; default: CPRINTS("C%d: Received unexpected VDM ACK for SVID %d", port, svid); @@ -261,6 +262,7 @@ void dpm_vdm_naked(int port, enum tcpci_msg_type type, uint16_t svid, intel_vdm_naked(port, type, vdm_cmd); break; } + __fallthrough; default: CPRINTS("C%d: Received unexpected VDM NAK for SVID %d", port, svid); diff --git a/common/usbc/usb_pe_drp_sm.c b/common/usbc/usb_pe_drp_sm.c index 2e3bffbf68..5a5aebc4b4 100644 --- a/common/usbc/usb_pe_drp_sm.c +++ b/common/usbc/usb_pe_drp_sm.c @@ -817,11 +817,11 @@ void pe_run(int port, int evt, int en) case SM_PAUSED: if (!en) break; - /* fall through */ + __fallthrough; case SM_INIT: pe_init(port); local_state[port] = SM_RUN; - /* fall through */ + __fallthrough; case SM_RUN: if (!en) { local_state[port] = SM_PAUSED; @@ -5997,8 +5997,8 @@ static void pe_init_vdm_modes_request_run(int port) dfp_consume_modes(port, sop, cnt, payload); break; } + __fallthrough; } - /* Fall Through */ case VDM_RESULT_NAK: /* PE_INIT_VDM_Modes_NAKed embedded here */ pd_set_modes_discovery(port, pe[port].tx_type, requested_svid, diff --git a/common/usbc/usb_prl_sm.c b/common/usbc/usb_prl_sm.c index d4bd5b9a6e..db9f460e61 100644 --- a/common/usbc/usb_prl_sm.c +++ b/common/usbc/usb_prl_sm.c @@ -696,11 +696,11 @@ void prl_run(int port, int evt, int en) case SM_PAUSED: if (!en) break; - /* fall through */ + __fallthrough; case SM_INIT: prl_init(port); local_state[port] = SM_RUN; - /* fall through */ + __fallthrough; case SM_RUN: if (!en) { /* Disable RX */ diff --git a/common/usbc/usb_retimer_fw_update.c b/common/usbc/usb_retimer_fw_update.c index 3f9b1b4c72..9b581ea872 100644 --- a/common/usbc/usb_retimer_fw_update.c +++ b/common/usbc/usb_retimer_fw_update.c @@ -116,7 +116,7 @@ int usb_retimer_fw_update_get_result(void) result = last_result; break; } - /* fall through */ + __fallthrough; case USB_RETIMER_FW_UPDATE_RESUME_PD: result = pd_is_port_enabled(cur_port); break; diff --git a/driver/als_si114x.c b/driver/als_si114x.c index 30f92e23d1..eba613be8b 100644 --- a/driver/als_si114x.c +++ b/driver/als_si114x.c @@ -317,10 +317,13 @@ static int si114x_set_chlist(const struct motion_sensor_t *s) switch (SI114X_NUM_LEDS) { case 3: reg |= SI114X_PARAM_CHLIST_EN_PS3; + __fallthrough; case 2: reg |= SI114X_PARAM_CHLIST_EN_PS2; + __fallthrough; case 1: reg |= SI114X_PARAM_CHLIST_EN_PS1; + __fallthrough; case 0: break; } diff --git a/driver/charger/bd9995x.c b/driver/charger/bd9995x.c index a6303d41b4..aa37bf4e8a 100644 --- a/driver/charger/bd9995x.c +++ b/driver/charger/bd9995x.c @@ -758,6 +758,7 @@ static enum ec_error_list bd9995x_get_status(int chgnum, int *status) break; case BD9995X_CMD_CHGOP_STATUS_BATTEMP_BATOPEN: *status &= ~CHARGER_BATTERY_PRESENT; + break; default: break; } diff --git a/driver/charger/rt946x.c b/driver/charger/rt946x.c index acf5dc012d..58b5c1adb4 100644 --- a/driver/charger/rt946x.c +++ b/driver/charger/rt946x.c @@ -1233,7 +1233,7 @@ static int rt946x_get_bc12_ilim(int charge_supplier) IS_ENABLED(CONFIG_CHARGE_RAMP_HW)) /* A conservative value to prevent a bad charger. */ return RT946X_AICR_TYP2MAX(USB_CHARGER_MAX_CURR_MA); - /* fallback */ + __fallthrough; case CHARGE_SUPPLIER_BC12_CDP: return USB_CHARGER_MAX_CURR_MA; case CHARGE_SUPPLIER_BC12_SDP: diff --git a/driver/tcpm/rt1718s.c b/driver/tcpm/rt1718s.c index a009e33323..07c14f7dd5 100644 --- a/driver/tcpm/rt1718s.c +++ b/driver/tcpm/rt1718s.c @@ -196,7 +196,7 @@ static int rt1718s_workaround(int port) RETURN_ERROR(rt1718s_update_bits8( port, RT1718S_VCONN_CONTROL_3, RT1718S_VCONN_CONTROL_3_VCONN_OVP_DEG, 0xFF)); - /* fallthrough */ + __fallthrough; case RT1718S_DEVICE_ID_ES2: RETURN_ERROR(rt1718s_update_bits8( port, TCPC_REG_FAULT_CTRL, diff --git a/include/common.h b/include/common.h index 72553161f5..97dddfc03f 100644 --- a/include/common.h +++ b/include/common.h @@ -192,6 +192,15 @@ */ #define __warn_unused_result __attribute__((warn_unused_result)) +/** + * @brief Attribute used to annotate intentional fallthrough between switch + * labels. + * + * See https://clang.llvm.org/docs/AttributeReference.html#fallthrough and + * https://gcc.gnu.org/onlinedocs/gcc/Statement-Attributes.html. + */ +#define __fallthrough __attribute__((fallthrough)) + /* * Macros for combining bytes into larger integers. _LE and _BE signify little * and big endian versions respectively. diff --git a/power/common.c b/power/common.c index c1675d31f2..65c1cf0779 100644 --- a/power/common.c +++ b/power/common.c @@ -521,12 +521,12 @@ static enum power_state power_common_state(void) break; case POWER_S4: - /* fallthrough */ + __fallthrough; case POWER_S3: - /* fallthrough */ + __fallthrough; case POWER_S0: #ifdef CONFIG_POWER_S0IX - /* fallthrough */ + __fallthrough; case POWER_S0ix: #endif /* Wait for a message */ diff --git a/power/intel_x86.c b/power/intel_x86.c index 1c9f2ef8c8..4fa3aa3c8e 100644 --- a/power/intel_x86.c +++ b/power/intel_x86.c @@ -381,7 +381,7 @@ enum power_state common_intel_x86_power_handle_state(enum power_state state) return POWER_S4; /* Power down to the next state */ case POWER_S5S3: - /* fallthrough */ + __fallthrough; case POWER_S4S3: if (!power_has_signals(IN_PGOOD_ALL_CORE)) { /* Required rail went away */ diff --git a/util/stm32mon.cc b/util/stm32mon.cc index 352158ae73..39837bd3dd 100644 --- a/util/stm32mon.cc +++ b/util/stm32mon.cc @@ -633,6 +633,7 @@ int wait_for_ack(int fd) } /* Do not break so that it can be handled as junk */ + __attribute__((fallthrough)); default: stat_resp[JUNK_IDX].event_count++; if (mode == MODE_SERIAL) diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index 84f5aeb97f..ae882e5640 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -56,6 +56,7 @@ endif() # Set extra compiler flags. zephyr_cc_option(-mno-unaligned-access) zephyr_cc_option(-fno-PIC) +zephyr_cc_option(-Wimplicit-fallthrough) if (DEFINED CONFIG_RISCV) zephyr_cc_option(-fsanitize=integer-divide-by-zero) diff --git a/zephyr/emul/emul_sn5s330.c b/zephyr/emul/emul_sn5s330.c index f957cd9e05..6a520ed195 100644 --- a/zephyr/emul/emul_sn5s330.c +++ b/zephyr/emul/emul_sn5s330.c @@ -227,15 +227,15 @@ static int sn5s330_emul_write_byte(const struct emul *emul, int reg, /* Specially check for read-only reg */ switch (reg) { case SN5S330_INT_TRIP_RISE_REG1: - /* fallthrough */ + __fallthrough; case SN5S330_INT_TRIP_RISE_REG2: - /* fallthrough */ + __fallthrough; case SN5S330_INT_TRIP_RISE_REG3: - /* fallthrough */ + __fallthrough; case SN5S330_INT_TRIP_FALL_REG1: - /* fallthrough */ + __fallthrough; case SN5S330_INT_TRIP_FALL_REG2: - /* fallthrough */ + __fallthrough; case SN5S330_INT_TRIP_FALL_REG3: reg_to_write = sn5s330_emul_get_reg_ptr(data, reg); /* Clearing any bit deasserts /INT interrupt signal */ @@ -245,15 +245,15 @@ static int sn5s330_emul_write_byte(const struct emul *emul, int reg, *reg_to_write = val; break; case SN5S330_INT_STATUS_REG1: - /* fallthrough */ + __fallthrough; case SN5S330_INT_STATUS_REG2: - /* fallthrough */ + __fallthrough; case SN5S330_INT_STATUS_REG3: __ASSERT(false, "Write to an unverified-as-safe read-only register on " "0x%x", reg); - /* fallthrough for checkpath */ + __fallthrough; default: reg_to_write = sn5s330_emul_get_reg_ptr(data, reg); *reg_to_write = val; diff --git a/zephyr/emul/tcpc/emul_ps8xxx.c b/zephyr/emul/tcpc/emul_ps8xxx.c index 22972bf084..57cc2c85f5 100644 --- a/zephyr/emul/tcpc/emul_ps8xxx.c +++ b/zephyr/emul/tcpc/emul_ps8xxx.c @@ -235,6 +235,7 @@ static int ps8xxx_emul_tcpc_write_byte(const struct emul *emul, int reg, if (prod_id != PS8815_PRODUCT_ID) { break; } + __fallthrough; case PS8XXX_REG_I2C_DEBUGGING_ENABLE: case PS8XXX_REG_MUX_IN_HPD_ASSERTION: case PS8XXX_REG_BIST_CONT_MODE_BYTE0: @@ -282,6 +283,7 @@ static int ps8xxx_emul_tcpc_finish_write(const struct emul *emul, int reg, if (prod_id != PS8815_PRODUCT_ID) { break; } + __fallthrough; case PS8XXX_REG_I2C_DEBUGGING_ENABLE: case PS8XXX_REG_MUX_IN_HPD_ASSERTION: case PS8XXX_REG_BIST_CONT_MODE_BYTE0: @@ -399,11 +401,13 @@ static int ps8xxx_emul_read_byte_workhorse(const struct emul *emul, int reg, *val = data->dci_cfg; return 0; } + __fallthrough; case PS8XXX_EMUL_PORT_GPIO: if (reg == PS8805_REG_GPIO_CONTROL) { *val = data->gpio_ctrl; return 0; } + __fallthrough; case PS8XXX_EMUL_PORT_INVAL: LOG_ERR("Invalid I2C address"); return -EIO; @@ -481,11 +485,13 @@ static int ps8xxx_emul_write_byte_workhorse(const struct emul *emul, int reg, data->dci_cfg = val; return 0; } + __fallthrough; case PS8XXX_EMUL_PORT_GPIO: if (reg == PS8805_REG_GPIO_CONTROL) { data->gpio_ctrl = val; return 0; } + __fallthrough; case PS8XXX_EMUL_PORT_INVAL: LOG_ERR("Invalid I2C address"); return -EIO; diff --git a/zephyr/emul/tcpc/emul_tcpci.c b/zephyr/emul/tcpc/emul_tcpci.c index e19f7a2726..aa4e508489 100644 --- a/zephyr/emul/tcpc/emul_tcpci.c +++ b/zephyr/emul/tcpc/emul_tcpci.c @@ -1211,7 +1211,7 @@ static int tcpci_emul_handle_transmit(const struct emul *emul) case TCPCI_MSG_TX_HARD_RESET: tcpci_emul_disable_pd_msg_delivery(emul); tcpci_emul_reset_mask_regs(ctx); - /* fallthrough */ + __fallthrough; case TCPCI_MSG_CABLE_RESET: /* * Cable and Hard reset are special and set success and fail @@ -1259,13 +1259,13 @@ int tcpci_emul_handle_write(const struct emul *emul, int reg, int msg_len) ctx->write_data &= ~TCPC_REG_ALERT_RX_STATUS; } } - /* fallthrough */ + __fallthrough; case TCPC_REG_FAULT_STATUS: case TCPC_REG_ALERT_EXT: /* Clear bits where TCPM set 1 */ get_reg(ctx, reg, &alert_val); ctx->write_data = alert_val & (~ctx->write_data); - /* fallthrough */ + __fallthrough; case TCPC_REG_ALERT_MASK: case TCPC_REG_POWER_STATUS_MASK: case TCPC_REG_FAULT_STATUS_MASK: @@ -1344,6 +1344,7 @@ int tcpci_emul_handle_write(const struct emul *emul, int reg, int msg_len) switch (reg_bytes) { case 2: rsvd_mask = tcpci_emul_rsvd_mask[reg + 1]; + __fallthrough; case 1: rsvd_mask <<= 8; rsvd_mask |= tcpci_emul_rsvd_mask[reg]; diff --git a/zephyr/emul/tcpc/emul_tcpci_partner_common.c b/zephyr/emul/tcpc/emul_tcpci_partner_common.c index 1785acda51..22a9ddb91e 100644 --- a/zephyr/emul/tcpc/emul_tcpci_partner_common.c +++ b/zephyr/emul/tcpc/emul_tcpci_partner_common.c @@ -1076,7 +1076,7 @@ tcpci_partner_common_sop_msg_handler(struct tcpci_partner_data *data, tcpci_partner_common_clear_ams_ctrl_msg(data); - /* Fall through */ + __fallthrough; case PD_CTRL_ACCEPT: if (data->wait_for_response) { if (data->in_soft_reset) { |