Workaround fixes to shut up some cppcheck '--inconclusive' whinings.
This commit is contained in:
parent
81a2e62abd
commit
4cad5d4df4
|
@ -204,13 +204,13 @@ void CheckClass::initVar(const std::string &varname, const Scope *scope, std::ve
|
|||
}
|
||||
}
|
||||
|
||||
void CheckClass::assignAllVar(std::vector<Usage> &usage)
|
||||
void CheckClass::assignAllVar(std::vector<Usage> &usage) const
|
||||
{
|
||||
for (size_t i = 0; i < usage.size(); ++i)
|
||||
usage[i].assign = true;
|
||||
}
|
||||
|
||||
void CheckClass::clearAllVar(std::vector<Usage> &usage)
|
||||
void CheckClass::clearAllVar(std::vector<Usage> &usage) const
|
||||
{
|
||||
for (size_t i = 0; i < usage.size(); ++i) {
|
||||
usage[i].assign = false;
|
||||
|
|
|
@ -209,13 +209,13 @@ private:
|
|||
* @brief set all variables in list assigned
|
||||
* @param usage reference to usage vector
|
||||
*/
|
||||
void assignAllVar(std::vector<Usage> &usage);
|
||||
void assignAllVar(std::vector<Usage> &usage) const;
|
||||
|
||||
/**
|
||||
* @brief set all variables in list not assigned and not initialized
|
||||
* @param usage reference to usage vector
|
||||
*/
|
||||
void clearAllVar(std::vector<Usage> &usage);
|
||||
void clearAllVar(std::vector<Usage> &usage) const;
|
||||
|
||||
/**
|
||||
* @brief parse a scope for a constructor or member function and set the "init" flags in the provided varlist
|
||||
|
|
|
@ -352,12 +352,12 @@ void CheckMemoryLeak::reportErr(const std::list<const Token *> &callstack, Sever
|
|||
Check::reportError(errmsg);
|
||||
}
|
||||
|
||||
void CheckMemoryLeak::memleakError(const Token *tok, const std::string &varname)
|
||||
void CheckMemoryLeak::memleakError(const Token *tok, const std::string &varname) const
|
||||
{
|
||||
reportErr(tok, Severity::error, "memleak", "Memory leak: " + varname);
|
||||
}
|
||||
|
||||
void CheckMemoryLeak::memleakUponReallocFailureError(const Token *tok, const std::string &varname)
|
||||
void CheckMemoryLeak::memleakUponReallocFailureError(const Token *tok, const std::string &varname) const
|
||||
{
|
||||
reportErr(tok, Severity::error, "memleakOnRealloc", "Common realloc mistake: \'" + varname + "\' nulled but not freed upon failure");
|
||||
}
|
||||
|
@ -370,22 +370,22 @@ void CheckMemoryLeak::resourceLeakError(const Token *tok, const std::string &var
|
|||
reportErr(tok, Severity::error, "resourceLeak", errmsg);
|
||||
}
|
||||
|
||||
void CheckMemoryLeak::deallocDeallocError(const Token *tok, const std::string &varname)
|
||||
void CheckMemoryLeak::deallocDeallocError(const Token *tok, const std::string &varname) const
|
||||
{
|
||||
reportErr(tok, Severity::error, "deallocDealloc", "Deallocating a deallocated pointer: " + varname);
|
||||
}
|
||||
|
||||
void CheckMemoryLeak::deallocuseError(const Token *tok, const std::string &varname)
|
||||
void CheckMemoryLeak::deallocuseError(const Token *tok, const std::string &varname) const
|
||||
{
|
||||
reportErr(tok, Severity::error, "deallocuse", "Dereferencing '" + varname + "' after it is deallocated / released");
|
||||
}
|
||||
|
||||
void CheckMemoryLeak::mismatchSizeError(const Token *tok, const std::string &sz)
|
||||
void CheckMemoryLeak::mismatchSizeError(const Token *tok, const std::string &sz) const
|
||||
{
|
||||
reportErr(tok, Severity::error, "mismatchSize", "The given size " + sz + " is mismatching");
|
||||
}
|
||||
|
||||
void CheckMemoryLeak::mismatchAllocDealloc(const std::list<const Token *> &callstack, const std::string &varname)
|
||||
void CheckMemoryLeak::mismatchAllocDealloc(const std::list<const Token *> &callstack, const std::string &varname) const
|
||||
{
|
||||
reportErr(callstack, Severity::error, "mismatchAllocDealloc", "Mismatching allocation and deallocation: " + varname);
|
||||
}
|
||||
|
|
|
@ -133,7 +133,7 @@ public:
|
|||
* @param tok token where memory is leaked
|
||||
* @param varname name of variable
|
||||
*/
|
||||
void memleakError(const Token *tok, const std::string &varname);
|
||||
void memleakError(const Token *tok, const std::string &varname) const;
|
||||
|
||||
/**
|
||||
* Report that there is a resource leak (fopen/popen/etc)
|
||||
|
@ -147,11 +147,11 @@ public:
|
|||
* @param tok token where error occurs
|
||||
* @param varname name of variable
|
||||
*/
|
||||
void deallocDeallocError(const Token *tok, const std::string &varname);
|
||||
void deallocuseError(const Token *tok, const std::string &varname);
|
||||
void mismatchSizeError(const Token *tok, const std::string &sz);
|
||||
void mismatchAllocDealloc(const std::list<const Token *> &callstack, const std::string &varname);
|
||||
void memleakUponReallocFailureError(const Token *tok, const std::string &varname);
|
||||
void deallocDeallocError(const Token *tok, const std::string &varname) const;
|
||||
void deallocuseError(const Token *tok, const std::string &varname) const;
|
||||
void mismatchSizeError(const Token *tok, const std::string &sz) const;
|
||||
void mismatchAllocDealloc(const std::list<const Token *> &callstack, const std::string &varname) const;
|
||||
void memleakUponReallocFailureError(const Token *tok, const std::string &varname) const;
|
||||
|
||||
/** What type of allocated memory does the given function return? */
|
||||
AllocType functionReturnType(const Token *tok, std::list<const Token *> *callstack = NULL) const;
|
||||
|
|
|
@ -917,7 +917,7 @@ void SymbolDatabase::addFunction(Scope **scope, const Token **tok, const Token *
|
|||
path_length++;
|
||||
}
|
||||
|
||||
if (count) {
|
||||
if (tok1 && count) {
|
||||
path = tok1->str() + " :: " + path;
|
||||
path_length++;
|
||||
}
|
||||
|
@ -1248,6 +1248,8 @@ void Function::addArguments(const SymbolDatabase *symbolDatabase, const Function
|
|||
} else if (tok->str() == "<")
|
||||
level++;
|
||||
}
|
||||
if (!tok) // something is wrong so just bail
|
||||
return;
|
||||
}
|
||||
|
||||
tok = tok->next();
|
||||
|
|
Loading…
Reference in New Issue