Skip to content

Commit 9dd3360

Browse files
committed
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.
1 parent 603a37b commit 9dd3360

6 files changed

Lines changed: 19 additions & 15 deletions

File tree

cli/cppcheckexecutor.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ bool CppCheckExecutor::parseFromArgs(CppCheck *cppcheck, int argc, const char* c
107107
bool warned = false;
108108
std::vector<std::string> ignored = parser.GetIgnoredPaths();
109109
std::vector<std::string>::iterator iterIgnored = ignored.begin();
110-
for (unsigned int i = ignored.size() - 1; i != UINT_MAX; --i) {
110+
for (size_t i = 0 ; i < ignored.size();) {
111111
const std::string extension = Path::getFilenameExtension(ignored[i]);
112112
if (extension == ".h" || extension == ".hpp") {
113113
ignored.erase(iterIgnored + i);
@@ -116,12 +116,13 @@ bool CppCheckExecutor::parseFromArgs(CppCheck *cppcheck, int argc, const char* c
116116
std::cout << "cppcheck: Please use --suppress for ignoring results from the header files." << std::endl;
117117
warned = true; // Warn only once
118118
}
119-
}
119+
} else
120+
++i;
120121
}
121122

122123
PathMatch matcher(parser.GetIgnoredPaths());
123124
std::vector<std::string>::iterator iterBegin = filenames.begin();
124-
for (unsigned int i = filenames.size() - 1; i != UINT_MAX; i--) {
125+
for (size_t i = 0 ; i < filenames.size();) {
125126
#if defined(_WIN32)
126127
// For Windows we want case-insensitive path matching
127128
const bool caseSensitive = false;
@@ -130,6 +131,8 @@ bool CppCheckExecutor::parseFromArgs(CppCheck *cppcheck, int argc, const char* c
130131
#endif
131132
if (matcher.Match(filenames[i], caseSensitive))
132133
filenames.erase(iterBegin + i);
134+
else
135+
++i;
133136
}
134137
} else {
135138
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[])
177180
}
178181

179182
long processedsize = 0;
180-
for (unsigned int c = 0; c < _filenames.size(); c++) {
183+
for (size_t c = 0; c < _filenames.size(); c++) {
181184
returnValue += cppCheck.check(_filenames[c]);
182185
if (_filesizes.find(_filenames[c]) != _filesizes.end()) {
183186
processedsize += _filesizes[_filenames[c]];
@@ -269,13 +272,13 @@ void CppCheckExecutor::reportProgress(const std::string &filename, const char st
269272
}
270273
}
271274

272-
void CppCheckExecutor::reportStatus(unsigned int fileindex, unsigned int filecount, long sizedone, long sizetotal)
275+
void CppCheckExecutor::reportStatus(size_t fileindex, size_t filecount, long sizedone, long sizetotal)
273276
{
274277
if (filecount > 1) {
275278
std::ostringstream oss;
276279
oss << fileindex << "/" << filecount
277280
<< " files checked " <<
278-
(sizetotal > 0 ? static_cast<long>(static_cast<double>(sizedone) / sizetotal*100) : 0)
281+
(sizetotal > 0 ? static_cast<long>(static_cast<long double>(sizedone) / sizetotal*100) : 0)
279282
<< "% done";
280283
std::cout << oss.str() << std::endl;
281284
}

cli/cppcheckexecutor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class CppCheckExecutor : public ErrorLogger {
8181
* @param sizedone The sum of sizes of the files checked.
8282
* @param sizetotal The total sizes of the files.
8383
*/
84-
static void reportStatus(unsigned int fileindex, unsigned int filecount, long sizedone, long sizetotal);
84+
static void reportStatus(size_t fileindex, size_t filecount, long sizedone, long sizetotal);
8585

8686
protected:
8787

gui/gui.cppcheck

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<project version="1">
33
<includedir>
44
<dir name="../lib"/>
5+
<dir name="."/>
56
<dir name="temp"/>
67
</includedir>
78
<paths>

lib/checkclass.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,12 +1365,12 @@ static unsigned int countParameters(const Token *tok)
13651365
++parlevel;
13661366

13671367
else if (tok->str() == ")") {
1368-
if (!parlevel)
1368+
if (parlevel <=1)
13691369
break;
13701370
--parlevel;
13711371
}
13721372

1373-
else if (!parlevel && tok->str() == ",") {
1373+
else if (parlevel==1 && tok->str() == ",") {
13741374
++numpar;
13751375
}
13761376
}

lib/symboldatabase.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ class Function {
353353
functionScope(NULL) {
354354
}
355355

356-
unsigned int argCount() const {
356+
size_t argCount() const {
357357
return argumentList.size();
358358
}
359359
unsigned int initializedArgCount() const;

lib/tokenize.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2892,7 +2892,7 @@ void Tokenizer::simplifyTemplatesUseDefaultArgumentValues(const std::list<Token
28922892
* @param patternAfter pattern that must match the tokens after the ">"
28932893
* @return match => true
28942894
*/
2895-
static bool simplifyTemplatesInstantiateMatch(const Token *instance, const std::string &name, unsigned int numberOfArguments, const char patternAfter[])
2895+
static bool simplifyTemplatesInstantiateMatch(const Token *instance, const std::string &name, size_t numberOfArguments, const char patternAfter[])
28962896
{
28972897
if (!Token::simpleMatch(instance, (name + " <").c_str()))
28982898
return false;
@@ -4028,7 +4028,7 @@ void Tokenizer::simplifySizeof()
40284028

40294029
else if (Token::Match(tok, "sizeof ( * %var% )") || Token::Match(tok, "sizeof ( %var% [ %num% ] )")) {
40304030
// Some default value..
4031-
unsigned int sz = 0;
4031+
size_t sz = 0;
40324032

40334033
unsigned int varid = tok->tokAt((tok->strAt(2) == "*") ? 3 : 2)->varId();
40344034
if (varid != 0) {
@@ -4045,11 +4045,11 @@ void Tokenizer::simplifySizeof()
40454045
sz = sizeOfType(tok->tokAt(2));
40464046
if (sz == 0)
40474047
continue;
4048-
sz = sz * static_cast<unsigned int>(MathLib::toLongNumber(tok->strAt(4)));
4048+
sz *= static_cast<unsigned long>(MathLib::toLongNumber(tok->strAt(4)));
40494049
}
40504050

40514051
if (sz > 0) {
4052-
tok->str(MathLib::toString<unsigned int>(sz));
4052+
tok->str(MathLib::toString<size_t>(sz));
40534053
Token::eraseTokens(tok, tok->next()->link()->next());
40544054
}
40554055
}
@@ -9693,7 +9693,7 @@ void Tokenizer::printUnknownTypes()
96939693
if (var->typeStartToken() == var->typeEndToken())
96949694
name = var->typeStartToken()->str();
96959695

9696-
// complcated type
9696+
// complicated type
96979697
else {
96989698
const Token *tok = var->typeStartToken();
96999699
int level = 0;

0 commit comments

Comments
 (0)