Code improvement, remove unnecessary part

Fix pedantic warnings, add initializers.

Close #12093
pull/12118/head
ozone10 2022-09-03 17:13:06 +02:00 committed by Don Ho
parent ea1e9295eb
commit ebe7648ee1
20 changed files with 63 additions and 71 deletions

View File

@ -77,7 +77,7 @@ bool isInListA(const char *token, const char *list)
if ((!token) || (!list))
return false;
char word[64];
char word[64] = { '\0' };
size_t i = 0;
size_t j = 0;
for (size_t len = strlen(list); i <= len; ++i)
@ -100,7 +100,7 @@ bool isInListA(const char *token, const char *list)
}
}
return false;
};
}
int EncodingMapper::getEncodingFromIndex(int index) const
{
@ -144,4 +144,4 @@ int EncodingMapper::getEncodingFromString(const char *encodingAlias) const
}
}
return enc;
}
}

View File

@ -240,7 +240,7 @@ void HashFromFilesDlg::doDialog(bool isRTL)
// Adjust the position in the center
goToCenter();
};
}
void HashFromTextDlg::generateHash()
{
@ -500,4 +500,4 @@ void HashFromTextDlg::doDialog(bool isRTL)
// Adjust the position in the center
goToCenter();
};
}

View File

@ -3358,7 +3358,7 @@ void Notepad_plus::setLanguage(LangType langType)
_subEditView.execute(SCI_SETDOCPOINTER, 0, prev);
_subEditView.restoreCurrentPosPreStep();
}
};
}
LangType Notepad_plus::menuID2LangType(int cmdID)
{
@ -4703,7 +4703,7 @@ static generic_string extractSymbol(TCHAR firstChar, TCHAR secondChar, const TCH
}
}
return generic_string(extracted);
};
}
bool Notepad_plus::doBlockComment(comment_mode currCommentMode)
{

View File

@ -43,14 +43,14 @@ void addText2Combo(const TCHAR * txt2add, HWND hCombo)
i = ::SendMessage(hCombo, CB_INSERTSTRING, 0, reinterpret_cast<LPARAM>(txt2add));
::SendMessage(hCombo, CB_SETCURSEL, i, 0);
};
}
generic_string getTextFromCombo(HWND hCombo)
{
TCHAR str[FINDREPLACE_MAXLENGTH] = { '\0' };
::SendMessage(hCombo, WM_GETTEXT, FINDREPLACE_MAXLENGTH - 1, reinterpret_cast<LPARAM>(str));
return generic_string(str);
};
}
void delLeftWordInEdit(HWND hEdit)
{
@ -75,7 +75,7 @@ void delLeftWordInEdit(HWND hEdit)
::SendMessage(hEdit, EM_SETSEL, (WPARAM)wordstart, (LPARAM)cursor);
::SendMessage(hEdit, EM_REPLACESEL, (WPARAM)TRUE, reinterpret_cast<LPARAM>(L""));
}
};
}
int Searching::convertExtendedToString(const TCHAR * query, TCHAR * result, int length)
{ //query may equal to result, since it always gets smaller

View File

@ -3387,7 +3387,7 @@ bool ScintillaEditView::getIndicatorRange(size_t indicatorNumber, size_t* from,
if (to) *to = endPos;
if (cur) *cur = curPos;
return true;
};
}
void ScintillaEditView::scrollPosToCenter(size_t pos)
@ -3894,7 +3894,7 @@ pair<size_t, size_t> ScintillaEditView::getSelectedCharsAndLinesCount(long long
}
return selectedCharsAndLines;
};
}
size_t ScintillaEditView::getUnicodeSelectedLength() const
{
@ -3909,7 +3909,7 @@ size_t ScintillaEditView::getUnicodeSelectedLength() const
}
return length;
};
}
void ScintillaEditView::markedTextToClipboard(int indiStyle, bool doAll /*= false*/)

View File

@ -84,7 +84,7 @@ void convertTo(TCHAR *dest, int destLen, const TCHAR *toConvert, const TCHAR *pr
}
}
dest[index] = '\0';
};
}
bool SharedParametersDialog::setPropertyByCheck(HWND hwnd, WPARAM id, bool & bool2set)
{

View File

@ -51,4 +51,4 @@ namespace Utf8 { // could be a static class, instead of a namespace, if it needs
++charContinuationBytes;
return startingIndex-charContinuationBytes;
}
};
}

View File

@ -584,7 +584,7 @@ bool Utf16_Iter::get(utf8 *c)
return true;
}
return false;
};
}
void Utf16_Iter::pushout(ubyte c)
{

View File

@ -43,8 +43,8 @@ static const WORD DotPattern[] =
class Gripper final
{
public:
Gripper() = default;;
Gripper() = default;
void init(HINSTANCE hInst, HWND hParent) {
_hInst = hInst;
_hParent = hParent;
@ -148,4 +148,3 @@ private:
// get layout direction
bool _isRTL = false;
};

View File

@ -493,7 +493,7 @@ void ViewZoneDlg::doDialog()
create(win10 ? IDD_VIEWZONE : IDD_VIEWZONE_CLASSIC);
}
display();
};
}
intptr_t CALLBACK ViewZoneDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
{

View File

@ -70,7 +70,7 @@ vector<generic_string> split(const generic_string & string2split, TCHAR sep)
}
}
return splitedStrings;
};
}
bool isRelatedRootFolder(const generic_string & relatedRoot, const generic_string & subFolder)
{
@ -1605,7 +1605,7 @@ LPCWSTR explainAction(DWORD dwAction)
default:
return L"BAD DATA";
}
};
}
DWORD WINAPI FolderUpdater::watching(void *params)

View File

@ -25,7 +25,7 @@ void ShortcutMapper::initTabs()
{
HWND hTab = _hTabCtrl = ::GetDlgItem(_hSelf, IDC_BABYGRID_TABBAR);
NppDarkMode::subclassTabControl(hTab);
TCITEM tie;
TCITEM tie{};
tie.mask = TCIF_TEXT;
for (size_t i = 0; i < _nbTab; ++i)
@ -39,8 +39,8 @@ void ShortcutMapper::initTabs()
TabCtrl_SetCurSel(_hTabCtrl, int(_currentState));
// force alignment to babygrid
RECT rcTab;
WINDOWPLACEMENT wp;
RECT rcTab{};
WINDOWPLACEMENT wp{};
wp.length = sizeof(wp);
::GetWindowPlacement(hTab, &wp);
@ -56,13 +56,13 @@ void ShortcutMapper::getClientRect(RECT & rc) const
{
Window::getClientRect(rc);
RECT tabRect, btnRect;
RECT tabRect{}, btnRect{};
::GetClientRect(::GetDlgItem(_hSelf, IDC_BABYGRID_TABBAR), &tabRect);
int tabH = tabRect.bottom - tabRect.top;
int paddingTop = tabH / 2;
rc.top += tabH + paddingTop;
RECT infoRect, filterRect;
RECT infoRect{}, filterRect{};
::GetClientRect(::GetDlgItem(_hSelf, IDC_BABYGRID_INFO), &infoRect);
::GetClientRect(::GetDlgItem(_hSelf, IDC_BABYGRID_FILTER), &filterRect);
::GetClientRect(::GetDlgItem(_hSelf, IDOK), &btnRect);
@ -104,7 +104,7 @@ generic_string ShortcutMapper::getTabString(size_t i) const
void ShortcutMapper::initBabyGrid()
{
RECT rect;
RECT rect{};
getClientRect(rect);
_lastHomeRow.resize(5, 1);
@ -190,7 +190,7 @@ generic_string ShortcutMapper::getTextFromCombo(HWND hCombo)
::SendMessage(hCombo, WM_GETTEXT, NB_MAX, reinterpret_cast<LPARAM>(str));
generic_string res(str);
return stringToLower(res);
};
}
bool ShortcutMapper::isFilterValid(Shortcut sc)
{
@ -1065,7 +1065,7 @@ intptr_t CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARA
case BGN_CELLRCLICKED: //a cell was clicked in the properties grid
{
POINT p;
POINT p{};
::GetCursorPos(&p);
if (!_rightClickMenu.isCreated())
{

View File

@ -29,7 +29,7 @@ void IconList::init(HINSTANCE hInst, int iconSize)
_hImglst = ImageList_Create(iconSize, iconSize, ILC_COLOR32 | ILC_MASK, 0, nbMore);
if (!_hImglst)
throw std::runtime_error("IconList::create : ImageList_Create() function returns null");
};
}
void IconList::create(int iconSize, HINSTANCE hInst, int *iconIDArray, int iconIDArraySize)
{
@ -39,7 +39,7 @@ void IconList::create(int iconSize, HINSTANCE hInst, int *iconIDArray, int iconI
for (int i = 0 ; i < iconIDArraySize ; ++i)
addIcon(iconIDArray[i]);
};
}
void IconList::addIcon(int iconID) const
{
@ -49,14 +49,13 @@ void IconList::addIcon(int iconID) const
ImageList_AddIcon(_hImglst, hIcon);
::DestroyIcon(hIcon);
};
}
void IconList::addIcon(HICON hIcon) const
{
if (hIcon)
ImageList_AddIcon(_hImglst, hIcon);
};
}
bool IconList::changeIcon(size_t index, const TCHAR *iconLocation) const
{
@ -141,7 +140,7 @@ void ToolBarIcons::reInit(int size)
HDC dcScreen = ::GetDC(NULL);
BITMAP bmp;
BITMAP bmp{};
int nbByteBmp = ::GetObject(iconinfoSrc.hbmColor, sizeof(BITMAP), &bmp);
if (!nbByteBmp)
@ -216,7 +215,6 @@ void ToolBarIcons::reInit(int size)
}
}
void ToolBarIcons::create(HINSTANCE hInst, int iconSize)
{
_iconListVector.push_back(IconList());
@ -250,7 +248,3 @@ void ToolBarIcons::destroy()
_iconListVector[HLIST_DISABLE].destroy();
_iconListVector[HLIST_DISABLE2].destroy();
}

View File

@ -126,7 +126,7 @@ void expandNppEnvironmentStrs(const TCHAR *strSrc, TCHAR *stringDest, size_t str
{
if (iEnd != -1)
{
TCHAR str[MAX_PATH];
TCHAR str[MAX_PATH] = { '\0' };
int m = 0;
for (int k = iBegin ; k <= iEnd ; ++k)
str[m++] = strSrc[k];
@ -425,4 +425,4 @@ void RunDlg::doDialog(bool isRTL)
// Adjust the position in the center
goToCenter();
::SetFocus(::GetDlgItem(_hSelf, IDC_COMBO_RUN_PATH));
};
}

View File

@ -130,7 +130,7 @@ bool ToolBar::init( HINSTANCE hInst, HWND hPere, toolBarStatusType type, ToolBar
_toolBarIcons.init(buttonUnitArray, arraySize, _vDynBtnReg);
_toolBarIcons.create(_hInst, iconSize);
INITCOMMONCONTROLSEX icex;
INITCOMMONCONTROLSEX icex{};
icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
icex.dwICC = ICC_WIN95_CLASSES|ICC_COOL_CLASSES|ICC_BAR_CLASSES|ICC_USEREX_CLASSES;
InitCommonControlsEx(&icex);
@ -207,11 +207,11 @@ void ToolBar::destroy()
::DestroyWindow(_hSelf);
_hSelf = NULL;
_toolBarIcons.destroy();
};
}
int ToolBar::getWidth() const
{
RECT btnRect;
RECT btnRect{};
int totalWidth = 0;
for (size_t i = 0; i < _nbCurrentButtons; ++i)
{
@ -279,7 +279,7 @@ void ToolBar::reset(bool create)
if (create && _hSelf)
{
//Store current button state information
TBBUTTON tempBtn;
TBBUTTON tempBtn{};
for (size_t i = 0; i < _nbCurrentButtons; ++i)
{
::SendMessage(_hSelf, TB_GETBUTTON, i, reinterpret_cast<LPARAM>(&tempBtn));
@ -421,7 +421,7 @@ void ToolBar::registerDynBtn(UINT messageID, toolbarIcons* iconHandles, HICON ab
// Note: Register of buttons only possible before init!
if ((_hSelf == NULL) && (messageID != 0) && (iconHandles->hToolbarBmp != NULL))
{
DynamicCmdIcoBmp dynList;
DynamicCmdIcoBmp dynList{};
dynList._message = messageID;
dynList._hBmp = iconHandles->hToolbarBmp;
@ -431,7 +431,7 @@ void ToolBar::registerDynBtn(UINT messageID, toolbarIcons* iconHandles, HICON ab
}
else
{
BITMAP bmp;
BITMAP bmp{};
int nbByteBmp = ::GetObject(dynList._hBmp, sizeof(BITMAP), &bmp);
if (!nbByteBmp)
{
@ -463,7 +463,7 @@ void ToolBar::registerDynBtnDM(UINT messageID, toolbarIconsWithDarkMode* iconHan
if ((_hSelf == NULL) && (messageID != 0) && (iconHandles->hToolbarBmp != NULL) &&
(iconHandles->hToolbarIcon != NULL) && (iconHandles->hToolbarIconDarkMode != NULL))
{
DynamicCmdIcoBmp dynList;
DynamicCmdIcoBmp dynList{};
dynList._message = messageID;
dynList._hBmp = iconHandles->hToolbarBmp;
dynList._hIcon = iconHandles->hToolbarIcon;
@ -554,7 +554,7 @@ LRESULT CALLBACK RebarSubclass(
case WM_ERASEBKGND:
if (NppDarkMode::isEnabled())
{
RECT rc;
RECT rc{};
GetClientRect(hWnd, &rc);
FillRect((HDC)wParam, &rc, NppDarkMode::getDarkerBackgroundBrush());
return TRUE;
@ -582,7 +582,7 @@ void ReBar::init(HINSTANCE hInst, HWND hPere)
SetWindowSubclass(_hSelf, RebarSubclass, g_rebarSubclassID, 0);
REBARINFO rbi;
REBARINFO rbi{};
ZeroMemory(&rbi, sizeof(REBARINFO));
rbi.cbSize = sizeof(REBARINFO);
rbi.fMask = 0;
@ -726,4 +726,3 @@ bool ReBar::isIDTaken(int id)
}
return false;
}

View File

@ -43,7 +43,7 @@ int CALLBACK ListViewCompareProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSo
return result;
return (0 - result);
};
}
void VerticalFileSwitcher::startColumnSort()
{
@ -121,7 +121,7 @@ intptr_t CALLBACK VerticalFileSwitcher::run_dlgProc(UINT message, WPARAM wParam,
if (i == -1 || i >= nbItem)
return TRUE;
LVITEM item;
LVITEM item{};
item.mask = LVIF_PARAM;
item.iItem = i;
ListView_GetItem(((LPNMHDR)lParam)->hwndFrom, &item);
@ -150,7 +150,7 @@ intptr_t CALLBACK VerticalFileSwitcher::run_dlgProc(UINT message, WPARAM wParam,
if (i == -1 || i >= nbItem)
return TRUE;
LVITEM item;
LVITEM item{};
item.mask = LVIF_PARAM;
item.iItem = i;
ListView_GetItem(((LPNMHDR)lParam)->hwndFrom, &item);
@ -162,7 +162,7 @@ intptr_t CALLBACK VerticalFileSwitcher::run_dlgProc(UINT message, WPARAM wParam,
if (nbSelectedFiles() >= 1)
{
// Redirect NM_RCLICK message to Notepad_plus handle
NMHDR nmhdr;
NMHDR nmhdr{};
nmhdr.code = NM_RCLICK;
nmhdr.hwndFrom = _hSelf;
nmhdr.idFrom = ::GetDlgCtrlID(nmhdr.hwndFrom);
@ -206,7 +206,7 @@ intptr_t CALLBACK VerticalFileSwitcher::run_dlgProc(UINT message, WPARAM wParam,
LPNMHEADER test = (LPNMHEADER)lParam;
HWND hwndHD = ListView_GetHeader(_fileListView.getHSelf());
TCHAR HDtext[MAX_PATH];
TCHAR HDtext[MAX_PATH] = { '\0' };
HDITEM hdi = {};
hdi.mask = HDI_TEXT | HDI_WIDTH;
hdi.pszText = HDtext;
@ -231,7 +231,7 @@ intptr_t CALLBACK VerticalFileSwitcher::run_dlgProc(UINT message, WPARAM wParam,
if (i == -1)
return TRUE;
LVITEM item;
LVITEM item{};
item.mask = LVIF_PARAM;
item.iItem = i;
ListView_GetItem(((LPNMHDR)lParam)->hwndFrom, &item);
@ -336,7 +336,7 @@ void VerticalFileSwitcher::display(bool toShow) const
{
DockingDlgInterface::display(toShow);
_fileListView.ensureVisibleCurrentItem(); // without this call the current item may stay above visible area after the program startup
};
}
void VerticalFileSwitcher::activateDoc(TaskLstFnStatus *tlfs) const
{
@ -359,7 +359,7 @@ void VerticalFileSwitcher::activateDoc(TaskLstFnStatus *tlfs) const
int VerticalFileSwitcher::setHeaderOrder(int columnIndex)
{
HWND hListView = _fileListView.getHSelf();
LVCOLUMN lvc;
LVCOLUMN lvc{};
lvc.mask = LVCF_FMT;
//strip HDF_SORTUP and HDF_SORTDOWN from old sort column
@ -397,7 +397,7 @@ int VerticalFileSwitcher::setHeaderOrder(int columnIndex)
void VerticalFileSwitcher::updateHeaderArrow()
{
HWND hListView = _fileListView.getHSelf();
LVCOLUMN lvc;
LVCOLUMN lvc{};
lvc.mask = LVCF_FMT;
SendMessage(hListView, LVM_GETCOLUMN, _lastSortingColumn, reinterpret_cast<LPARAM>(&lvc));

View File

@ -560,7 +560,7 @@ void WindowsDlg::updateButtonState()
int WindowsDlg::doDialog()
{
return static_cast<int>(DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_WINDOWS), _hParent, dlgProc, reinterpret_cast<LPARAM>(this)));
};
}
BOOL WindowsDlg::onInitDialog()
{

View File

@ -55,7 +55,7 @@ static size_t keyTranslate(size_t keyIn) {
case VK_OEM_6: return ']';
default: return keyIn;
}
};
}
struct KeyCombo {
bool _isCtrl = false;

View File

@ -79,7 +79,7 @@ void LastRecentFileList::switchMode()
_hParentMenu = NULL;
}
_hasSeparators = false;
};
}
void LastRecentFileList::updateMenu()
{
@ -181,14 +181,14 @@ void LastRecentFileList::add(const TCHAR *fn)
}
_lrfl.push_front(itemToAdd);
updateMenu();
};
}
void LastRecentFileList::remove(const TCHAR *fn)
{
int index = find(fn);
if (index != -1)
remove(index);
};
}
void LastRecentFileList::remove(size_t index)
{
@ -202,7 +202,7 @@ void LastRecentFileList::remove(size_t index)
--_size;
updateMenu();
}
};
}
void LastRecentFileList::clear()
@ -232,7 +232,7 @@ generic_string & LastRecentFileList::getItem(int id)
if (i == _size)
i = 0;
return _lrfl.at(i)._name; //if not found, return first
};
}
generic_string & LastRecentFileList::getIndex(int index)
{

View File

@ -182,7 +182,7 @@ bool isInList(const TCHAR *token2Find, ParamVector& params, bool eraseArg = true
}
}
return false;
};
}
bool getParamVal(TCHAR c, ParamVector & params, generic_string & value)
{
@ -248,7 +248,7 @@ intptr_t getNumberFromParam(char paramName, ParamVector & params, bool & isParam
}
isParamePresent = true;
return static_cast<intptr_t>(_ttoi64(numStr.c_str()));
};
}
generic_string getEasterEggNameFromParam(ParamVector & params, unsigned char & type)
{