From a26c397417aa1b4b88e699cc0dcee5fc9f556deb Mon Sep 17 00:00:00 2001 From: Krzysiek Egzmont Date: Mon, 16 Oct 2023 16:52:32 +0200 Subject: [PATCH] Remove fall-through pragmas --- Makefile | 2 +- app/app.c | 10 +++------- app/dtmf.c | 6 +----- app/menu.c | 21 ++++----------------- audio.c | 9 ++------- radio.c | 12 ++---------- ui/inputbox.c | 2 +- ui/main.c | 25 ++++++------------------- ui/menu.c | 5 ----- ui/status.c | 2 +- 10 files changed, 21 insertions(+), 73 deletions(-) diff --git a/Makefile b/Makefile index 3a4b722..91a51f9 100644 --- a/Makefile +++ b/Makefile @@ -209,7 +209,7 @@ endif #CFLAGS += -Wpadded # catch any and all warnings -#CFLAGS += -Wextra +CFLAGS += -Wextra CFLAGS += -DPRINTF_INCLUDE_CONFIG_H CFLAGS += -DGIT_HASH=\"$(GIT_HASH)\" diff --git a/app/app.c b/app/app.c index 9849ead..0dde658 100644 --- a/app/app.c +++ b/app/app.c @@ -650,9 +650,6 @@ static void MR_NextChannel(void) if (enabled) { - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wimplicit-fallthrough=" - switch (gCurrentScanList) { case SCAN_NEXT_CHAN_SCANLIST1: @@ -667,7 +664,7 @@ static void MR_NextChannel(void) break; } } - + [[fallthrough]]; case SCAN_NEXT_CHAN_SCANLIST2: if (chan2 >= 0) { @@ -678,6 +675,7 @@ static void MR_NextChannel(void) break; } } + [[fallthrough]]; // this bit doesn't yet work if the other VFO is a frequency case SCAN_NEXT_CHAN_DUAL_WATCH: @@ -701,8 +699,6 @@ static void MR_NextChannel(void) chan = 0xff; break; } - - #pragma GCC diagnostic pop } if (!enabled || chan == 0xff) @@ -2229,7 +2225,7 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) } } - if ((Key >= KEY_0 && Key <= KEY_9) || Key == KEY_F) + if (Key <= KEY_9 || Key == KEY_F) { if (gScanStateDir != SCAN_OFF || gCssScanMode != CSS_SCAN_MODE_OFF) { // FREQ/CTCSS/DCS scanning diff --git a/app/dtmf.c b/app/dtmf.c index 68b23eb..0be3e76 100644 --- a/app/dtmf.c +++ b/app/dtmf.c @@ -356,13 +356,11 @@ void DTMF_HandleRequest(void) gUpdateDisplay = true; - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wimplicit-fallthrough=" - switch (gEeprom.DTMF_DECODE_RESPONSE) { case DTMF_DEC_RESPONSE_BOTH: gDTMF_DecodeRingCountdown_500ms = DTMF_decode_ring_countdown_500ms; + [[fallthrough]]; case DTMF_DEC_RESPONSE_REPLY: gDTMF_ReplyState = DTMF_REPLY_AAAAA; break; @@ -376,8 +374,6 @@ void DTMF_HandleRequest(void) break; } - #pragma GCC diagnostic pop - if (gDTMF_IsGroupCall) gDTMF_ReplyState = DTMF_REPLY_NONE; } diff --git a/app/menu.c b/app/menu.c index 2c035e1..8a0fb90 100644 --- a/app/menu.c +++ b/app/menu.c @@ -403,11 +403,9 @@ void MENU_AcceptSetting(void) gRequestSaveChannel = 1; return; - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wimplicit-fallthrough=" - case MENU_T_CTCS: pConfig = &gTxVfo->freq_config_TX; + [[fallthrough]]; case MENU_R_CTCS: if (gSubMenuSelection == 0) { @@ -434,8 +432,6 @@ void MENU_AcceptSetting(void) gRequestSaveChannel = 1; return; - #pragma GCC diagnostic pop - case MENU_SFT_D: gTxVfo->TX_OFFSET_FREQUENCY_DIRECTION = gSubMenuSelection; gRequestSaveChannel = 1; @@ -1154,7 +1150,7 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) if (edit_index < 10) { - if (Key >= KEY_0 && Key <= KEY_9) + if (Key <= KEY_9) { edit[edit_index] = '0' + Key - KEY_0; @@ -1177,9 +1173,6 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) if (!gIsInSubMenu) { - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wimplicit-fallthrough=" - switch (gInputBoxIndex) { case 2: @@ -1199,7 +1192,7 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) gInputBox[0] = gInputBox[1]; gInputBoxIndex = 1; - + [[fallthrough]]; case 1: Value = gInputBox[0]; if (Value > 0 && Value <= gMenuListCount) @@ -1211,8 +1204,6 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) break; } - #pragma GCC diagnostic pop - gInputBoxIndex = 0; gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; @@ -1653,9 +1644,6 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction) VFO = 0; - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wimplicit-fallthrough=" - switch (GetCurrentMenuId()) { case MENU_DEL_CH: @@ -1666,6 +1654,7 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction) case MENU_SLIST2: VFO = 1; + [[fallthrough]]; case MENU_SLIST1: bCheckScanList = true; break; @@ -1676,8 +1665,6 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction) return; } - #pragma GCC diagnostic pop - Channel = RADIO_FindNextChannel(gSubMenuSelection + Direction, Direction, bCheckScanList, VFO); if (Channel != 0xFF) gSubMenuSelection = Channel; diff --git a/audio.c b/audio.c index b46fd44..acecd9d 100644 --- a/audio.c +++ b/audio.c @@ -142,9 +142,6 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep) SYSTEM_DelayMs(60); - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wimplicit-fallthrough=" - switch (Beep) { case BEEP_880HZ_60MS_TRIPLE_BEEP: @@ -152,14 +149,14 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep) SYSTEM_DelayMs(60); BK4819_EnterTxMute(); SYSTEM_DelayMs(20); - + [[fallthrough]]; case BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL: case BEEP_500HZ_60MS_DOUBLE_BEEP: BK4819_ExitTxMute(); SYSTEM_DelayMs(60); BK4819_EnterTxMute(); SYSTEM_DelayMs(20); - + [[fallthrough]]; case BEEP_1KHZ_60MS_OPTIONAL: BK4819_ExitTxMute(); Duration = 60; @@ -184,8 +181,6 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep) break; } - #pragma GCC diagnostic pop - SYSTEM_DelayMs(Duration); BK4819_EnterTxMute(); SYSTEM_DelayMs(20); diff --git a/radio.c b/radio.c index 4ec19fc..f627dfb 100644 --- a/radio.c +++ b/radio.c @@ -581,13 +581,11 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0) BK4819_ToggleGpioOut(BK4819_GPIO0_PIN28_GREEN, false); - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wimplicit-fallthrough=" - switch (Bandwidth) { default: Bandwidth = BK4819_FILTER_BW_WIDE; + [[fallthrough]]; case BK4819_FILTER_BW_WIDE: case BK4819_FILTER_BW_NARROW: #ifdef ENABLE_AM_FIX @@ -599,8 +597,6 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0) break; } - #pragma GCC diagnostic pop - BK4819_ToggleGpioOut(BK4819_GPIO1_PIN29_RED, false); BK4819_SetupPowerAmplifier(0, 0); @@ -835,13 +831,11 @@ void RADIO_SetTxParameters(void) BK4819_ToggleGpioOut(BK4819_GPIO6_PIN2, false); - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wimplicit-fallthrough=" - switch (Bandwidth) { default: Bandwidth = BK4819_FILTER_BW_WIDE; + [[fallthrough]]; case BK4819_FILTER_BW_WIDE: case BK4819_FILTER_BW_NARROW: #ifdef ENABLE_AM_FIX @@ -853,8 +847,6 @@ void RADIO_SetTxParameters(void) break; } - #pragma GCC diagnostic pop - BK4819_SetFrequency(gCurrentVfo->pTX->Frequency); // TX compressor diff --git a/ui/inputbox.c b/ui/inputbox.c index e352cce..3731bb1 100644 --- a/ui/inputbox.c +++ b/ui/inputbox.c @@ -29,7 +29,7 @@ void INPUTBOX_Append(const KEY_Code_t Digit) if (gInputBoxIndex == 0) memset(gInputBox, 10, sizeof(gInputBox)); - if (Digit >= KEY_0 && Digit != KEY_INVALID) + if (Digit != KEY_INVALID) gInputBox[gInputBoxIndex++] = (char)(Digit - KEY_0); } diff --git a/ui/main.c b/ui/main.c index 1348163..71f39df 100644 --- a/ui/main.c +++ b/ui/main.c @@ -14,10 +14,6 @@ * limitations under the License. */ - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wimplicit-fallthrough=" - #pragma GCC diagnostic pop - #include #include // abs() @@ -46,23 +42,18 @@ center_line_t center_line = CENTER_LINE_NONE; void UI_drawBars(uint8_t *p, const unsigned int level) { - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wimplicit-fallthrough=" - switch (level) { default: - case 7: memmove(p + 20, BITMAP_AntennaLevel6, sizeof(BITMAP_AntennaLevel6)); - case 6: memmove(p + 17, BITMAP_AntennaLevel5, sizeof(BITMAP_AntennaLevel5)); - case 5: memmove(p + 14, BITMAP_AntennaLevel4, sizeof(BITMAP_AntennaLevel4)); - case 4: memmove(p + 11, BITMAP_AntennaLevel3, sizeof(BITMAP_AntennaLevel3)); - case 3: memmove(p + 8, BITMAP_AntennaLevel2, sizeof(BITMAP_AntennaLevel2)); - case 2: memmove(p + 5, BITMAP_AntennaLevel1, sizeof(BITMAP_AntennaLevel1)); + case 7: memmove(p + 20, BITMAP_AntennaLevel6, sizeof(BITMAP_AntennaLevel6)); [[fallthrough]]; + case 6: memmove(p + 17, BITMAP_AntennaLevel5, sizeof(BITMAP_AntennaLevel5)); [[fallthrough]]; + case 5: memmove(p + 14, BITMAP_AntennaLevel4, sizeof(BITMAP_AntennaLevel4)); [[fallthrough]]; + case 4: memmove(p + 11, BITMAP_AntennaLevel3, sizeof(BITMAP_AntennaLevel3)); [[fallthrough]]; + case 3: memmove(p + 8, BITMAP_AntennaLevel2, sizeof(BITMAP_AntennaLevel2)); [[fallthrough]]; + case 2: memmove(p + 5, BITMAP_AntennaLevel1, sizeof(BITMAP_AntennaLevel1)); [[fallthrough]]; case 1: memmove(p + 0, BITMAP_Antenna, sizeof(BITMAP_Antenna)); break; case 0: memset( p + 0, 0, sizeof(BITMAP_Antenna)); break; } - - #pragma GCC diagnostic pop } #ifdef ENABLE_AUDIO_BAR @@ -501,8 +492,6 @@ void UI_DisplayMain(void) #endif - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wimplicit-fallthrough=" switch (gEeprom.CHANNEL_DISPLAY_MODE) { @@ -553,8 +542,6 @@ void UI_DisplayMain(void) break; } - - #pragma GCC diagnostic pop } else { // frequency mode diff --git a/ui/menu.c b/ui/menu.c index 7bc8700..d84942d 100644 --- a/ui/menu.c +++ b/ui/menu.c @@ -434,9 +434,6 @@ void UI_DisplayMenu(void) bool already_printed = false; - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wimplicit-fallthrough=" - switch (GetCurrentMenuId()) { case MENU_SQL: @@ -803,8 +800,6 @@ void UI_DisplayMenu(void) } } - #pragma GCC diagnostic pop - if (!already_printed) { // we now do multi-line text in a single string diff --git a/ui/status.c b/ui/status.c index 882182a..2a5c8f7 100644 --- a/ui/status.c +++ b/ui/status.c @@ -142,7 +142,7 @@ void UI_DisplayStatus(const bool test_display) x += sizeof(BITMAP_VOX) + 2; #endif - x = MAX(x, 61); + x = MAX(x, 61u); x1 = x; // KEY-LOCK indicator