diff options
author | Jochen Nitschke <j.nitschke+logerrit@ok.de> | 2017-08-13 11:48:46 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-08-13 14:02:29 +0200 |
commit | f70e978f4bf223d7edbb4c3a981f46938a3b3ed1 (patch) | |
tree | f5af3e54af9a56c526321410dc611240b5f64c6b /comphelper | |
parent | 0b133fdb67cc56fba46ec355283144e611e8bf83 (diff) |
cppcheck: variableScope
Change-Id: I4dfbd80cf06acb4968556a78d3eaf394757073dc
Reviewed-on: https://gerrit.libreoffice.org/41110
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'comphelper')
-rw-r--r-- | comphelper/source/windows/windows_process.cxx | 12 |
1 files changed, 5 insertions, 7 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) |