From 278f694f3a6dea9f542baa5821a9ca136ff40e95 Mon Sep 17 00:00:00 2001 From: ozone10 Date: Wed, 15 Feb 2023 21:28:04 +0100 Subject: [PATCH] Code enhancement: fix GCC implicit-fallthrough warnings Fix #13142, close #13143 --- PowerEditor/src/MISC/RegExt/regExtDlg.cpp | 1 + PowerEditor/src/Notepad_plus.cpp | 1 + PowerEditor/src/NppBigSwitch.cpp | 4 ++++ PowerEditor/src/NppCommands.cpp | 2 +- PowerEditor/src/ScintillaComponent/Buffer.cpp | 3 +++ PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp | 5 ++++- PowerEditor/src/ScintillaComponent/UserDefineDialog.cpp | 2 ++ PowerEditor/src/ScintillaComponent/columnEditor.cpp | 2 ++ PowerEditor/src/WinControls/AboutDlg/AboutDlg.cpp | 4 ++++ PowerEditor/src/WinControls/ColourPicker/ColourPopup.cpp | 6 ++++-- .../src/WinControls/ColourPicker/WordStyleDlg.cpp | 6 +++--- .../WinControls/FindCharsInRange/FindCharsInRange.cpp | 1 + PowerEditor/src/WinControls/Grid/BabyGrid.cpp | 2 +- PowerEditor/src/WinControls/Grid/ShortcutMapper.cpp | 7 +++++++ PowerEditor/src/WinControls/Preference/preferenceDlg.cpp | 9 +++++++++ 15 files changed, 47 insertions(+), 8 deletions(-) diff --git a/PowerEditor/src/MISC/RegExt/regExtDlg.cpp b/PowerEditor/src/MISC/RegExt/regExtDlg.cpp index 4cf2f7693..6dcd2dda6 100644 --- a/PowerEditor/src/MISC/RegExt/regExtDlg.cpp +++ b/PowerEditor/src/MISC/RegExt/regExtDlg.cpp @@ -326,6 +326,7 @@ intptr_t CALLBACK RegExtDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPa } // break; // no break here + [[fallthrough]]; } default : diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 265767612..7ece8aacf 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -1422,6 +1422,7 @@ void Notepad_plus::wsTabConvert(spaceTab whichWay) { onlyLeading = true; } + [[fallthrough]]; case space2TabAll: { bool nextChar = false; diff --git a/PowerEditor/src/NppBigSwitch.cpp b/PowerEditor/src/NppBigSwitch.cpp index 6380c4204..ad6c37496 100644 --- a/PowerEditor/src/NppBigSwitch.cpp +++ b/PowerEditor/src/NppBigSwitch.cpp @@ -1070,6 +1070,8 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa return nbDocPrimary; else if (lParam == SECOND_VIEW) return nbDocSecond; + else + return 0; } case NPPM_GETOPENFILENAMESPRIMARY: @@ -2345,6 +2347,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa nppParam.endSessionStart(); // ensure nppParam.makeEndSessionCritical(); // set our exit-flag to critical even if the bitmask has not the ENDSESSION_CRITICAL set // do not return 0 here and continue to the Notepad++ standard WM_CLOSE code-part (no verbose GUI there this time!!!) + [[fallthrough]]; } } // case WM_ENDSESSION: @@ -3290,6 +3293,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa { addHotSpot(pView); } + return TRUE; } case NPPM_INTERNAL_UPDATETEXTZONEPADDING: diff --git a/PowerEditor/src/NppCommands.cpp b/PowerEditor/src/NppCommands.cpp index 389455aa3..fa968b50a 100644 --- a/PowerEditor/src/NppCommands.cpp +++ b/PowerEditor/src/NppCommands.cpp @@ -373,8 +373,8 @@ void Notepad_plus::command(int id) _pEditView->execute(WM_COPY); checkClipboard(); _pEditView->execute(SCI_SETSEL, curPos, curPos); - break; } + break; } case IDM_EDIT_COPY_BINARY: diff --git a/PowerEditor/src/ScintillaComponent/Buffer.cpp b/PowerEditor/src/ScintillaComponent/Buffer.cpp index 6aee7bdec..e2aba716f 100644 --- a/PowerEditor/src/ScintillaComponent/Buffer.cpp +++ b/PowerEditor/src/ScintillaComponent/Buffer.cpp @@ -1636,11 +1636,14 @@ bool FileManager::loadFileData(Document doc, int64_t fileSize, const TCHAR * fil #endif break; case SC_STATUS_BADALLOC: + { pNativeSpeaker->messageBox("FileTooBigToOpen", _pNotepadPlus->_pEditView->getHSelf(), TEXT("File is too big to be opened by Notepad++"), TEXT("Exception: File size problem"), MB_OK | MB_APPLMODAL); + } + [[fallthrough]]; case SC_STATUS_FAILURE: default: _stprintf_s(szException, _countof(szException), TEXT("%d (Scintilla)"), sciStatus); diff --git a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp index ef1fd7fea..fedbb48b2 100644 --- a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp @@ -147,6 +147,7 @@ int Searching::convertExtendedToString(const TCHAR * query, TCHAR * result, int } } //not enough chars to make parameter, use default method as fallback + [[fallthrough]]; } default: @@ -1799,7 +1800,7 @@ intptr_t CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA nppParamInst._isFindReplacing = false; } } - + return TRUE; case IDC_REPLACE_OPENEDFILES : { @@ -5126,6 +5127,7 @@ intptr_t CALLBACK FindIncrementDlg::run_dlgProc(UINT message, WPARAM wParam, LPA return TRUE; } // otherwise, repeat the search + [[fallthrough]]; case IDM_SEARCH_FINDPREV: // Accel table: find prev case IDM_SEARCH_FINDNEXT: // Accel table: find next case IDC_INCFINDPREVOK: @@ -5158,6 +5160,7 @@ intptr_t CALLBACK FindIncrementDlg::run_dlgProc(UINT message, WPARAM wParam, LPA break; } // treat other edit notifications as unhandled + [[fallthrough]]; default: return DefWindowProc(getHSelf(), message, wParam, lParam); } diff --git a/PowerEditor/src/ScintillaComponent/UserDefineDialog.cpp b/PowerEditor/src/ScintillaComponent/UserDefineDialog.cpp index e192a8d79..ed7a13f00 100644 --- a/PowerEditor/src/ScintillaComponent/UserDefineDialog.cpp +++ b/PowerEditor/src/ScintillaComponent/UserDefineDialog.cpp @@ -1543,6 +1543,8 @@ intptr_t CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPA } ::SetScrollPos(_hSelf, SB_VERT, _yScrollPos, TRUE); ::ScrollWindow(_hSelf, 0, oldy-_yScrollPos, NULL, NULL); + + break; } case NPPM_MODELESSDIALOG : return ::SendMessage(_hParent, NPPM_MODELESSDIALOG, wParam, lParam); diff --git a/PowerEditor/src/ScintillaComponent/columnEditor.cpp b/PowerEditor/src/ScintillaComponent/columnEditor.cpp index e9e17c8b9..6c26913dd 100644 --- a/PowerEditor/src/ScintillaComponent/columnEditor.cpp +++ b/PowerEditor/src/ScintillaComponent/columnEditor.cpp @@ -436,8 +436,10 @@ intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR } break; } + break; } } + break; } default : diff --git a/PowerEditor/src/WinControls/AboutDlg/AboutDlg.cpp b/PowerEditor/src/WinControls/AboutDlg/AboutDlg.cpp index 2b4478e82..9a070126b 100644 --- a/PowerEditor/src/WinControls/AboutDlg/AboutDlg.cpp +++ b/PowerEditor/src/WinControls/AboutDlg/AboutDlg.cpp @@ -123,6 +123,7 @@ intptr_t CALLBACK AboutDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lPar default : break; } + break; } case WM_DESTROY : @@ -390,6 +391,7 @@ intptr_t CALLBACK DebugInfoDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM default: break; } + break; } case WM_DESTROY: @@ -538,6 +540,7 @@ intptr_t CALLBACK DoSaveOrNotBox::run_dlgProc(UINT message, WPARAM wParam, LPARA return TRUE; } } + break; } default: return FALSE; @@ -644,6 +647,7 @@ intptr_t CALLBACK DoSaveAllBox::run_dlgProc(UINT message, WPARAM wParam, LPARAM return TRUE; } } + break; } default: return FALSE; diff --git a/PowerEditor/src/WinControls/ColourPicker/ColourPopup.cpp b/PowerEditor/src/WinControls/ColourPicker/ColourPopup.cpp index 6115b5967..2a60db64a 100644 --- a/PowerEditor/src/WinControls/ColourPicker/ColourPopup.cpp +++ b/PowerEditor/src/WinControls/ColourPicker/ColourPopup.cpp @@ -162,6 +162,7 @@ intptr_t CALLBACK ColourPopup::run_dlgProc(UINT message, WPARAM wParam, LPARAM l break; } // *** FALL THROUGH *** + [[fallthrough]]; case ODA_SELECT: rc = pdis->rcItem; if (pdis->itemState & ODS_SELECTED) @@ -250,12 +251,13 @@ intptr_t CALLBACK ColourPopup::run_dlgProc(UINT message, WPARAM wParam, LPARAM l ::SendMessage(_hParent, WM_PICKUP_COLOR, _colour, 0); return TRUE; } + return FALSE; } - + default : return FALSE; } - + case WM_ACTIVATE : { if (LOWORD(wParam) == WA_INACTIVE) diff --git a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp index eda01e6e8..40d01c9fa 100644 --- a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp +++ b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp @@ -572,7 +572,7 @@ intptr_t CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM //return TRUE; } } - + break; } default : return FALSE; @@ -582,8 +582,8 @@ intptr_t CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM void WordStyleDlg::move2CtrlRight(int ctrlID, HWND handle2Move, int handle2MoveWidth, int handle2MoveHeight) { - POINT p; - RECT rc; + POINT p{}; + RECT rc{}; ::GetWindowRect(::GetDlgItem(_hSelf, ctrlID), &rc); p.x = rc.right + NppParameters::getInstance()._dpiManager.scaleX(5); diff --git a/PowerEditor/src/WinControls/FindCharsInRange/FindCharsInRange.cpp b/PowerEditor/src/WinControls/FindCharsInRange/FindCharsInRange.cpp index 809402617..1c4f8fd47 100644 --- a/PowerEditor/src/WinControls/FindCharsInRange/FindCharsInRange.cpp +++ b/PowerEditor/src/WinControls/FindCharsInRange/FindCharsInRange.cpp @@ -117,6 +117,7 @@ intptr_t CALLBACK FindCharsInRangeDlg::run_dlgProc(UINT message, WPARAM wParam, break; } } + break; } default : return FALSE; diff --git a/PowerEditor/src/WinControls/Grid/BabyGrid.cpp b/PowerEditor/src/WinControls/Grid/BabyGrid.cpp index 98a0c6ddf..53cecb520 100644 --- a/PowerEditor/src/WinControls/Grid/BabyGrid.cpp +++ b/PowerEditor/src/WinControls/Grid/BabyGrid.cpp @@ -2202,7 +2202,7 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { BGHS[SelfIndex].textcolor = RGB(0,0,0); } - + break; case WM_MOUSEMOVE: int x,y,r,c,t,z; x=LOWORD(lParam); diff --git a/PowerEditor/src/WinControls/Grid/ShortcutMapper.cpp b/PowerEditor/src/WinControls/Grid/ShortcutMapper.cpp index 1be525d31..0a6861654 100644 --- a/PowerEditor/src/WinControls/Grid/ShortcutMapper.cpp +++ b/PowerEditor/src/WinControls/Grid/ShortcutMapper.cpp @@ -1220,6 +1220,7 @@ intptr_t CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARA return TRUE; } } + break; } case IDC_BABYGRID_FILTER: { @@ -1229,7 +1230,13 @@ intptr_t CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARA } return TRUE; } + + default: + { + break; + } } + break; } default: diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp index 4faf71964..49db936eb 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp @@ -1458,6 +1458,8 @@ intptr_t CALLBACK DarkModeSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA delete _pLinkColorPicker; delete _pHotEdgeColorPicker; delete _pDisabledEdgeColorPicker; + + return TRUE; } case WM_COMMAND: @@ -1471,6 +1473,7 @@ intptr_t CALLBACK DarkModeSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA { NppDarkMode::handleSettingChange(nullptr, 0, true); } + [[fallthrough]]; case IDC_RADIO_DARKMODE_LIGHTMODE: case IDC_RADIO_DARKMODE_DARKMODE: { @@ -2377,6 +2380,8 @@ intptr_t CALLBACK NewDocumentSubDlg::run_dlgProc(UINT message, WPARAM wParam, LP break; } ::SendDlgItemMessage(_hSelf, IDC_COMBO_DEFAULTLANG, CB_SETCURSEL, j, 0); + + return TRUE; } case WM_CTLCOLORLISTBOX: @@ -2531,6 +2536,8 @@ intptr_t CALLBACK DefaultDirectorySubDlg::run_dlgProc(UINT message, WPARAM wPara ::EnableWindow(::GetDlgItem(_hSelf, IDD_OPENSAVEDIR_ALWAYSON_BROWSE_BUTTON), shouldActivated); ::SendDlgItemMessage(_hSelf, IDC_OPENSAVEDIR_CHECK_DRROPFOLDEROPENFILES, BM_SETCHECK, nppGUI._isFolderDroppedOpenFiles ? BST_CHECKED : BST_UNCHECKED, 0); + + return TRUE; } case WM_CTLCOLOREDIT: @@ -2662,6 +2669,8 @@ intptr_t CALLBACK RecentFilesHistorySubDlg::run_dlgProc(UINT message, WPARAM wPa ::SetDlgItemInt(_hSelf, IDC_CUSTOMIZELENGTHVAL_STATIC, length, FALSE); _customLenVal.init(_hInst, _hSelf); _customLenVal.create(::GetDlgItem(_hSelf, IDC_CUSTOMIZELENGTHVAL_STATIC), nullptr); + + return TRUE; } case WM_CTLCOLORDLG: