Improve constness

This commit is contained in:
jrp2014 2018-04-04 21:02:13 +02:00 committed by Daniel Marjamäki
parent 41a46364c8
commit 07b5afcdc6
4 changed files with 12 additions and 12 deletions

View File

@ -229,7 +229,7 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[])
} }
else if (std::strncmp(argv[i], "--suppress=", 11) == 0) { else if (std::strncmp(argv[i], "--suppress=", 11) == 0) {
std::string suppression = argv[i]+11; const std::string suppression = argv[i]+11;
const std::string errmsg(_settings->nomsg.addSuppressionLine(suppression)); const std::string errmsg(_settings->nomsg.addSuppressionLine(suppression));
if (!errmsg.empty()) { if (!errmsg.empty()) {
PrintMessage(errmsg); PrintMessage(errmsg);
@ -257,7 +257,7 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[])
if (argv[i][argv[i][3]=='='?4:17] != 0) { if (argv[i][argv[i][3]=='='?4:17] != 0) {
std::string paths = argv[i]+(argv[i][3]=='='?4:17); std::string paths = argv[i]+(argv[i][3]=='='?4:17);
for (;;) { for (;;) {
std::string::size_type pos = paths.find(';'); const std::string::size_type pos = paths.find(';');
if (pos == std::string::npos) { if (pos == std::string::npos) {
_settings->basePaths.push_back(Path::fromNativeSeparators(paths)); _settings->basePaths.push_back(Path::fromNativeSeparators(paths));
break; break;
@ -291,7 +291,7 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[])
// Define the XML file version (and enable XML output) // Define the XML file version (and enable XML output)
else if (std::strncmp(argv[i], "--xml-version=", 14) == 0) { else if (std::strncmp(argv[i], "--xml-version=", 14) == 0) {
std::string numberString(argv[i]+14); const std::string numberString(argv[i]+14);
std::istringstream iss(numberString); std::istringstream iss(numberString);
if (!(iss >> _settings->xml_version)) { if (!(iss >> _settings->xml_version)) {
@ -339,7 +339,7 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[])
// --error-exitcode=1 // --error-exitcode=1
else if (std::strncmp(argv[i], "--error-exitcode=", 17) == 0) { else if (std::strncmp(argv[i], "--error-exitcode=", 17) == 0) {
std::string temp = argv[i]+17; const std::string temp = argv[i]+17;
std::istringstream iss(temp); std::istringstream iss(temp);
if (!(iss >> _settings->exitCode)) { if (!(iss >> _settings->exitCode)) {
_settings->exitCode = 0; _settings->exitCode = 0;
@ -698,7 +698,7 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[])
// Specify platform // Specify platform
else if (std::strncmp(argv[i], "--platform=", 11) == 0) { else if (std::strncmp(argv[i], "--platform=", 11) == 0) {
std::string platform(11+argv[i]); const std::string platform(11+argv[i]);
if (platform == "win32A") if (platform == "win32A")
_settings->platform(Settings::Win32A); _settings->platform(Settings::Win32A);

View File

@ -161,7 +161,7 @@ bool CppCheckExecutor::parseFromArgs(CppCheck *cppcheck, int argc, const char* c
#endif #endif
if (!pathnames.empty()) { if (!pathnames.empty()) {
// Execute recursiveAddFiles() to each given file parameter // Execute recursiveAddFiles() to each given file parameter
PathMatch matcher(ignored, caseSensitive); const PathMatch matcher(ignored, caseSensitive);
for (std::vector<std::string>::const_iterator iter = pathnames.begin(); iter != pathnames.end(); ++iter) for (std::vector<std::string>::const_iterator iter = pathnames.begin(); iter != pathnames.end(); ++iter)
FileLister::recursiveAddFiles(_files, Path::toNativeSeparators(*iter), _settings->library.markupExtensions(), matcher); FileLister::recursiveAddFiles(_files, Path::toNativeSeparators(*iter), _settings->library.markupExtensions(), matcher);
} }

View File

@ -64,7 +64,7 @@ static BOOL MyFileExists(const std::string& path)
if (fa != INVALID_FILE_ATTRIBUTES && !(fa & FILE_ATTRIBUTE_DIRECTORY)) if (fa != INVALID_FILE_ATTRIBUTES && !(fa & FILE_ATTRIBUTE_DIRECTORY))
result = TRUE; result = TRUE;
#else #else
BOOL result = PathFileExistsA(path.c_str()); const BOOL result = PathFileExistsA(path.c_str());
#endif #endif
return result; return result;
} }
@ -89,7 +89,7 @@ void FileLister::addFiles(std::map<std::string, std::size_t> &files, const std::
const bool checkAllFilesInDir = (MyIsDirectory(cleanedPath) != FALSE); const bool checkAllFilesInDir = (MyIsDirectory(cleanedPath) != FALSE);
if (checkAllFilesInDir) { if (checkAllFilesInDir) {
char c = cleanedPath.back(); const char c = cleanedPath.back();
switch (c) { switch (c) {
case '\\': case '\\':
searchPattern += '*'; searchPattern += '*';
@ -104,7 +104,7 @@ void FileLister::addFiles(std::map<std::string, std::size_t> &files, const std::
basedir = cleanedPath + '\\'; basedir = cleanedPath + '\\';
} }
} else { } else {
std::string::size_type pos = cleanedPath.find_last_of('\\'); const std::string::size_type pos = cleanedPath.find_last_of('\\');
if (std::string::npos != pos) { if (std::string::npos != pos) {
basedir = cleanedPath.substr(0, pos + 1); basedir = cleanedPath.substr(0, pos + 1);
} }

View File

@ -389,7 +389,7 @@ unsigned int ThreadExecutor::check()
} }
} }
DWORD waitResult = WaitForMultipleObjects(_settings.jobs, threadHandles, TRUE, INFINITE); const DWORD waitResult = WaitForMultipleObjects(_settings.jobs, threadHandles, TRUE, INFINITE);
if (waitResult != WAIT_OBJECT_0) { if (waitResult != WAIT_OBJECT_0) {
if (waitResult == WAIT_FAILED) { if (waitResult == WAIT_FAILED) {
std::cerr << "#### .\nThreadExecutor::check wait failed, result: " << waitResult << " error: " << GetLastError() << std::endl; std::cerr << "#### .\nThreadExecutor::check wait failed, result: " << waitResult << " error: " << GetLastError() << std::endl;
@ -454,7 +454,7 @@ unsigned int __stdcall ThreadExecutor::threadProc(void *args)
LeaveCriticalSection(&threadExecutor->_fileSync); LeaveCriticalSection(&threadExecutor->_fileSync);
std::map<std::string, std::string>::const_iterator fileContent = threadExecutor->_fileContents.find(file); const std::map<std::string, std::string>::const_iterator fileContent = threadExecutor->_fileContents.find(file);
if (fileContent != threadExecutor->_fileContents.end()) { if (fileContent != threadExecutor->_fileContents.end()) {
// File content was given as a string // File content was given as a string
result += fileChecker.check(file, fileContent->second); result += fileChecker.check(file, fileContent->second);
@ -514,7 +514,7 @@ void ThreadExecutor::report(const ErrorLogger::ErrorMessage &msg, MessageType ms
// Alert only about unique errors // Alert only about unique errors
bool reportError = false; bool reportError = false;
std::string errmsg = msg.toString(_settings.verbose); const std::string errmsg = msg.toString(_settings.verbose);
EnterCriticalSection(&_errorSync); EnterCriticalSection(&_errorSync);
if (std::find(_errorList.begin(), _errorList.end(), errmsg) == _errorList.end()) { if (std::find(_errorList.begin(), _errorList.end(), errmsg) == _errorList.end()) {