Refactorization: Fixed several messages when self-checking cppcheck
This commit is contained in:
parent
8924e8af43
commit
8c70778b70
|
@ -138,7 +138,6 @@ void FileLister::recursiveAddFiles(std::map<std::string, std::size_t> &files, co
|
|||
|
||||
if (INVALID_HANDLE_VALUE != hFind) {
|
||||
FindClose(hFind);
|
||||
hFind = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -823,11 +823,9 @@ void CheckBufferOverrun::arrayIndexInForLoop(const Token *tok, const ArrayInfo &
|
|||
}
|
||||
}
|
||||
|
||||
bool usedInArray = false;
|
||||
|
||||
if (max_value > size) {
|
||||
if (tok3->strAt(1) == ")") {
|
||||
|
||||
bool usedInArray = false;
|
||||
for (const Token *loopTok = tok3->tokAt(2); loopTok->str() != "}" ; loopTok = loopTok->next()) {
|
||||
if (loopTok->varId() == arrayInfo.varid() && loopTok->tokAt(2)->varId() == counter_varid)
|
||||
usedInArray = true;
|
||||
|
|
|
@ -772,18 +772,16 @@ static void addtoken(Token **rettail, const Token *tok, const std::string &str)
|
|||
|
||||
Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::list<const Token *> callstack, const unsigned int varid, CheckMemoryLeak::AllocType &alloctype, CheckMemoryLeak::AllocType &dealloctype, bool classmember, unsigned int sz)
|
||||
{
|
||||
Token *rethead = 0, *rettail = 0;
|
||||
|
||||
// variables whose value depends on if(!var). If one of these variables
|
||||
// is used in a if-condition then generate "ifv" instead of "if".
|
||||
std::set<unsigned int> extravar;
|
||||
|
||||
// The first token should be ";"
|
||||
rethead = new Token(0);
|
||||
Token* rethead = new Token(0);
|
||||
rethead->str(";");
|
||||
rethead->linenr(tok->linenr());
|
||||
rethead->fileIndex(tok->fileIndex());
|
||||
rettail = rethead;
|
||||
Token* rettail = rethead;
|
||||
|
||||
int indentlevel = 0;
|
||||
int parlevel = 0;
|
||||
|
|
|
@ -905,10 +905,8 @@ std::string Preprocessor::getdef(std::string line, bool def)
|
|||
if (line.compare(0, 12, "#if defined ") == 0)
|
||||
line.erase(0, 11);
|
||||
else if (line.compare(0, 15, "#elif !defined(") == 0) {
|
||||
std::string::size_type pos = 0;
|
||||
|
||||
line.erase(0, 15);
|
||||
pos = line.find(")");
|
||||
std::string::size_type pos = line.find(")");
|
||||
// if pos == ::npos then another part of the code will complain
|
||||
// about the mismatch
|
||||
if (pos != std::string::npos)
|
||||
|
@ -2024,7 +2022,6 @@ void Preprocessor::handleIncludes(std::string &code, const std::string &filePath
|
|||
std::string::size_type pos = 0;
|
||||
std::string::size_type endfilePos = 0;
|
||||
std::set<std::string> handledFiles;
|
||||
endfilePos = pos;
|
||||
while ((pos = code.find("#include", pos)) != std::string::npos) {
|
||||
// Accept only includes that are at the start of a line
|
||||
if (pos > 0 && code[pos-1] != '\n') {
|
||||
|
|
|
@ -1123,14 +1123,13 @@ void Tokenizer::simplifyTypedef()
|
|||
// classes, casts, operators, and template parameters
|
||||
|
||||
// try to determine which category this substitution is
|
||||
bool isDerived = false;
|
||||
bool inCast = false;
|
||||
bool inTemplate = false;
|
||||
bool inOperator = false;
|
||||
bool inSizeof = false;
|
||||
|
||||
// check for derived class: class A : some_typedef {
|
||||
isDerived = Token::Match(tok2->previous(), "public|protected|private %type% {|,");
|
||||
bool isDerived = Token::Match(tok2->previous(), "public|protected|private %type% {|,");
|
||||
|
||||
// check for cast: (some_typedef) A or static_cast<some_typedef>(A)
|
||||
// todo: check for more complicated casts like: (const some_typedef *)A
|
||||
|
@ -3755,10 +3754,7 @@ bool Tokenizer::removeRedundantConditions()
|
|||
continue;
|
||||
|
||||
// Find matching else
|
||||
Token *elseTag = 0;
|
||||
|
||||
// Find the closing "}"
|
||||
elseTag = tok->linkAt(4)->next();
|
||||
Token *elseTag = tok->linkAt(4)->next();
|
||||
|
||||
bool boolValue = (tok->strAt(2) == "true");
|
||||
|
||||
|
|
Loading…
Reference in New Issue