diff --git a/cli/cppcheckexecutor.cpp b/cli/cppcheckexecutor.cpp index 6c47afe62..fbd2c3de8 100644 --- a/cli/cppcheckexecutor.cpp +++ b/cli/cppcheckexecutor.cpp @@ -107,7 +107,7 @@ bool CppCheckExecutor::parseFromArgs(CppCheck *cppcheck, int argc, const char* c bool warned = false; std::vector ignored = parser.GetIgnoredPaths(); std::vector::iterator iterIgnored = ignored.begin(); - for (unsigned int i = ignored.size() - 1; i != UINT_MAX; --i) { + for (size_t i = 0 ; i < ignored.size();) { const std::string extension = Path::getFilenameExtension(ignored[i]); if (extension == ".h" || extension == ".hpp") { ignored.erase(iterIgnored + i); @@ -116,12 +116,13 @@ bool CppCheckExecutor::parseFromArgs(CppCheck *cppcheck, int argc, const char* c std::cout << "cppcheck: Please use --suppress for ignoring results from the header files." << std::endl; warned = true; // Warn only once } - } + } else + ++i; } PathMatch matcher(parser.GetIgnoredPaths()); std::vector::iterator iterBegin = filenames.begin(); - for (unsigned int i = filenames.size() - 1; i != UINT_MAX; i--) { + for (size_t i = 0 ; i < filenames.size();) { #if defined(_WIN32) // For Windows we want case-insensitive path matching const bool caseSensitive = false; @@ -130,6 +131,8 @@ bool CppCheckExecutor::parseFromArgs(CppCheck *cppcheck, int argc, const char* c #endif if (matcher.Match(filenames[i], caseSensitive)) filenames.erase(iterBegin + i); + else + ++i; } } else { std::cout << "cppcheck: error: could not find or open any of the paths given." << std::endl; @@ -177,7 +180,7 @@ int CppCheckExecutor::check(int argc, const char* const argv[]) } long processedsize = 0; - for (unsigned int c = 0; c < _filenames.size(); c++) { + for (size_t c = 0; c < _filenames.size(); c++) { returnValue += cppCheck.check(_filenames[c]); if (_filesizes.find(_filenames[c]) != _filesizes.end()) { processedsize += _filesizes[_filenames[c]]; @@ -269,13 +272,13 @@ void CppCheckExecutor::reportProgress(const std::string &filename, const char st } } -void CppCheckExecutor::reportStatus(unsigned int fileindex, unsigned int filecount, long sizedone, long sizetotal) +void CppCheckExecutor::reportStatus(size_t fileindex, size_t filecount, long sizedone, long sizetotal) { if (filecount > 1) { std::ostringstream oss; oss << fileindex << "/" << filecount << " files checked " << - (sizetotal > 0 ? static_cast(static_cast(sizedone) / sizetotal*100) : 0) + (sizetotal > 0 ? static_cast(static_cast(sizedone) / sizetotal*100) : 0) << "% done"; std::cout << oss.str() << std::endl; } diff --git a/cli/cppcheckexecutor.h b/cli/cppcheckexecutor.h index 01cb74f62..4f0eafc42 100644 --- a/cli/cppcheckexecutor.h +++ b/cli/cppcheckexecutor.h @@ -81,7 +81,7 @@ public: * @param sizedone The sum of sizes of the files checked. * @param sizetotal The total sizes of the files. */ - static void reportStatus(unsigned int fileindex, unsigned int filecount, long sizedone, long sizetotal); + static void reportStatus(size_t fileindex, size_t filecount, long sizedone, long sizetotal); protected: diff --git a/gui/gui.cppcheck b/gui/gui.cppcheck index f4e5b2d9e..470f0bbfb 100644 --- a/gui/gui.cppcheck +++ b/gui/gui.cppcheck @@ -2,6 +2,7 @@ + diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index c46210835..3b8f43583 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -1365,12 +1365,12 @@ static unsigned int countParameters(const Token *tok) ++parlevel; else if (tok->str() == ")") { - if (!parlevel) + if (parlevel <=1) break; --parlevel; } - else if (!parlevel && tok->str() == ",") { + else if (parlevel==1 && tok->str() == ",") { ++numpar; } } diff --git a/lib/symboldatabase.h b/lib/symboldatabase.h index b5b4641f7..7fab477d1 100644 --- a/lib/symboldatabase.h +++ b/lib/symboldatabase.h @@ -353,7 +353,7 @@ public: functionScope(NULL) { } - unsigned int argCount() const { + size_t argCount() const { return argumentList.size(); } unsigned int initializedArgCount() const; diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 82ca14f10..5375c709f 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -2892,7 +2892,7 @@ void Tokenizer::simplifyTemplatesUseDefaultArgumentValues(const std::list" * @return match => true */ -static bool simplifyTemplatesInstantiateMatch(const Token *instance, const std::string &name, unsigned int numberOfArguments, const char patternAfter[]) +static bool simplifyTemplatesInstantiateMatch(const Token *instance, const std::string &name, size_t numberOfArguments, const char patternAfter[]) { if (!Token::simpleMatch(instance, (name + " <").c_str())) return false; @@ -4028,7 +4028,7 @@ void Tokenizer::simplifySizeof() else if (Token::Match(tok, "sizeof ( * %var% )") || Token::Match(tok, "sizeof ( %var% [ %num% ] )")) { // Some default value.. - unsigned int sz = 0; + size_t sz = 0; unsigned int varid = tok->tokAt((tok->strAt(2) == "*") ? 3 : 2)->varId(); if (varid != 0) { @@ -4045,11 +4045,11 @@ void Tokenizer::simplifySizeof() sz = sizeOfType(tok->tokAt(2)); if (sz == 0) continue; - sz = sz * static_cast(MathLib::toLongNumber(tok->strAt(4))); + sz *= static_cast(MathLib::toLongNumber(tok->strAt(4))); } if (sz > 0) { - tok->str(MathLib::toString(sz)); + tok->str(MathLib::toString(sz)); Token::eraseTokens(tok, tok->next()->link()->next()); } } @@ -9693,7 +9693,7 @@ void Tokenizer::printUnknownTypes() if (var->typeStartToken() == var->typeEndToken()) name = var->typeStartToken()->str(); - // complcated type + // complicated type else { const Token *tok = var->typeStartToken(); int level = 0;