From f70e978f4bf223d7edbb4c3a981f46938a3b3ed1 Mon Sep 17 00:00:00 2001 From: Jochen Nitschke Date: Sun, 13 Aug 2017 11:48:46 +0200 Subject: cppcheck: variableScope Change-Id: I4dfbd80cf06acb4968556a78d3eaf394757073dc Reviewed-on: https://gerrit.libreoffice.org/41110 Tested-by: Jenkins Reviewed-by: Noel Grandin --- comphelper/source/windows/windows_process.cxx | 12 +++---- sw/source/uibase/app/docsh2.cxx | 50 ++++++++++++++------------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/comphelper/source/windows/windows_process.cxx b/comphelper/source/windows/windows_process.cxx index 1c782d7a289f..ccebbd712bf0 100644 --- a/comphelper/source/windows/windows_process.cxx +++ b/comphelper/source/windows/windows_process.cxx @@ -19,7 +19,6 @@ */ static int ArgStrLen(const wchar_t *s) { - int backslashes = 0; int i = wcslen(s); BOOL hasDoubleQuote = wcschr(s, L'"') != nullptr; // Only add doublequotes if the string contains a space or a tab @@ -32,6 +31,7 @@ static int ArgStrLen(const wchar_t *s) if (hasDoubleQuote) { + int backslashes = 0; while (*s) { if (*s == '\\') @@ -67,7 +67,6 @@ static int ArgStrLen(const wchar_t *s) */ static wchar_t* ArgToString(wchar_t *d, const wchar_t *s) { - int backslashes = 0; BOOL hasDoubleQuote = wcschr(s, L'"') != nullptr; // Only add doublequotes if the string contains a space or a tab BOOL addDoubleQuotes = wcspbrk(s, L" \t") != nullptr; @@ -80,7 +79,7 @@ static wchar_t* ArgToString(wchar_t *d, const wchar_t *s) if (hasDoubleQuote) { - int i; + int backslashes = 0; while (*s) { if (*s == '\\') @@ -92,7 +91,7 @@ static wchar_t* ArgToString(wchar_t *d, const wchar_t *s) if (*s == '"') { // Escape the doublequote and all backslashes preceding the doublequote - for (i = 0; i <= backslashes; ++i) + for (int i = 0; i <= backslashes; ++i) { *d = '\\'; ++d; @@ -131,11 +130,10 @@ static wchar_t* ArgToString(wchar_t *d, const wchar_t *s) wchar_t* MakeCommandLine(int argc, wchar_t **argv) { - int i; int len = 0; // The + 1 of the last argument handles the allocation for null termination - for (i = 0; i < argc; ++i) + for (int i = 0; i < argc; ++i) len += ArgStrLen(argv[i]) + 1; // Protect against callers that pass 0 arguments @@ -147,7 +145,7 @@ MakeCommandLine(int argc, wchar_t **argv) return nullptr; wchar_t *c = s; - for (i = 0; i < argc; ++i) + for (int i = 0; i < argc; ++i) { c = ArgToString(c, argv[i]); if (i + 1 != argc) diff --git a/sw/source/uibase/app/docsh2.cxx b/sw/source/uibase/app/docsh2.cxx index 7dc36f163a1e..c0c662b9d9aa 100644 --- a/sw/source/uibase/app/docsh2.cxx +++ b/sw/source/uibase/app/docsh2.cxx @@ -887,34 +887,36 @@ void SwDocShell::Execute(SfxRequest& rReq) 0 }; - const char* aHTMLHelpIds[] = - { - HID_SEND_HTML_CTRL_PUSHBUTTON_OK, - HID_SEND_HTML_CTRL_PUSHBUTTON_CANCEL, - HID_SEND_HTML_CTRL_LISTBOX_FILTER, - HID_SEND_HTML_CTRL_CONTROL_FILEVIEW, - HID_SEND_HTML_CTRL_EDIT_FILEURL, - HID_SEND_HTML_CTRL_CHECKBOX_AUTOEXTENSION, - HID_SEND_HTML_CTRL_LISTBOX_TEMPLATE, - "" - }; - - const char* aMasterHelpIds[] = - { - HID_SEND_MASTER_CTRL_PUSHBUTTON_OK, - HID_SEND_MASTER_CTRL_PUSHBUTTON_CANCEL, - HID_SEND_MASTER_CTRL_LISTBOX_FILTER, - HID_SEND_MASTER_CTRL_CONTROL_FILEVIEW, - HID_SEND_MASTER_CTRL_EDIT_FILEURL, - HID_SEND_MASTER_CTRL_CHECKBOX_AUTOEXTENSION, - HID_SEND_MASTER_CTRL_LISTBOX_TEMPLATE, - "" - }; - if (bCreateHtml) + { + const char* aHTMLHelpIds[] = + { + HID_SEND_HTML_CTRL_PUSHBUTTON_OK, + HID_SEND_HTML_CTRL_PUSHBUTTON_CANCEL, + HID_SEND_HTML_CTRL_LISTBOX_FILTER, + HID_SEND_HTML_CTRL_CONTROL_FILEVIEW, + HID_SEND_HTML_CTRL_EDIT_FILEURL, + HID_SEND_HTML_CTRL_CHECKBOX_AUTOEXTENSION, + HID_SEND_HTML_CTRL_LISTBOX_TEMPLATE, + "" + }; aDlgHelper.SetControlHelpIds( nControlIds, aHTMLHelpIds ); + } else + { + const char* aMasterHelpIds[] = + { + HID_SEND_MASTER_CTRL_PUSHBUTTON_OK, + HID_SEND_MASTER_CTRL_PUSHBUTTON_CANCEL, + HID_SEND_MASTER_CTRL_LISTBOX_FILTER, + HID_SEND_MASTER_CTRL_CONTROL_FILEVIEW, + HID_SEND_MASTER_CTRL_EDIT_FILEURL, + HID_SEND_MASTER_CTRL_CHECKBOX_AUTOEXTENSION, + HID_SEND_MASTER_CTRL_LISTBOX_TEMPLATE, + "" + }; aDlgHelper.SetControlHelpIds( nControlIds, aMasterHelpIds ); + } uno::Reference < XFilePicker2 > xFP = aDlgHelper.GetFilePicker(); std::shared_ptr pFlt; -- cgit