Permalink
Browse files

Fix some complainted choices made in my older commits.

Note: probably you should do 'make clean' before using 'make' to rebuild it again. Maybe it's me but 'make' reports various errors when linking.
  • Loading branch information...
1 parent 603a37b commit 9dd3360cd65617636fd458ba22f948c3817d5df2 Edoardo Prezioso committed Nov 1, 2011
Showing with 19 additions and 15 deletions.
  1. +9 −6 cli/cppcheckexecutor.cpp
  2. +1 −1 cli/cppcheckexecutor.h
  3. +1 −0 gui/gui.cppcheck
  4. +2 −2 lib/checkclass.cpp
  5. +1 −1 lib/symboldatabase.h
  6. +5 −5 lib/tokenize.cpp
@@ -107,7 +107,7 @@ bool CppCheckExecutor::parseFromArgs(CppCheck *cppcheck, int argc, const char* c
bool warned = false;
std::vector<std::string> ignored = parser.GetIgnoredPaths();
std::vector<std::string>::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<std::string>::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<long>(static_cast<double>(sizedone) / sizetotal*100) : 0)
+ (sizetotal > 0 ? static_cast<long>(static_cast<long double>(sizedone) / sizetotal*100) : 0)
@kimmov
kimmov Nov 1, 2011

Seriously, where do you get ideas to these kind of changes?

<< "% done";
std::cout << oss.str() << std::endl;
}
@@ -81,7 +81,7 @@ class CppCheckExecutor : public ErrorLogger {
* @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:
View
@@ -2,6 +2,7 @@
<project version="1">
<includedir>
<dir name="../lib"/>
+ <dir name="."/>
@kimmov
kimmov Nov 1, 2011

Why do you think this is needed? And what this has to do with your commit message?

@edward-san
edward-san Nov 1, 2011

Sorry, I forgot to mention it. It is related to commit 4d888d8 . Some gui/temp headers reported missing includes from gui/ folder.

@kimmov
kimmov Nov 1, 2011

I think it is an error to have gui/temp in includedir list to begin with. The directory contains files that are generated from header files in gui. The header files in gui should really contain all the information Cppcheck needs.

@kimmov
kimmov Nov 7, 2011

I forgot one thing - ui_*.h files get currently created to gui/temp directory. And those are needed for proper checking. So in current configuration gui/temp is needed. That could be fixed by creating ui_*.h files to own directory and adding that to the project. That is if somebody still cares about GUI...

Another possibility (more generally usable too) is to add feature to allow suppressing header files. So one can tell to Cppcheck: "these header files are not present, don't try to find them and don't complain about them".

<dir name="temp"/>
</includedir>
<paths>
View
@@ -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;
}
}
@@ -353,7 +353,7 @@ class Function {
functionScope(NULL) {
}
- unsigned int argCount() const {
+ size_t argCount() const {
return argumentList.size();
}
unsigned int initializedArgCount() const;
View
@@ -2892,7 +2892,7 @@ void Tokenizer::simplifyTemplatesUseDefaultArgumentValues(const std::list<Token
* @param patternAfter pattern that must match the tokens after the ">"
* @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<unsigned int>(MathLib::toLongNumber(tok->strAt(4)));
+ sz *= static_cast<unsigned long>(MathLib::toLongNumber(tok->strAt(4)));
}
if (sz > 0) {
- tok->str(MathLib::toString<unsigned int>(sz));
+ tok->str(MathLib::toString<size_t>(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;

0 comments on commit 9dd3360

Please sign in to comment.