Removed some dead code and improved one function to use reference instead of a copy.
This commit is contained in:
parent
0747cfceb4
commit
6b16b7482a
|
@ -49,20 +49,6 @@ CheckDangerousFunctionsClass::~CheckDangerousFunctionsClass()
|
|||
|
||||
}
|
||||
|
||||
// Modified version of 'ReportError' that also reports the callstack
|
||||
void CheckDangerousFunctionsClass::ReportError(const std::string &errmsg)
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
std::list<const Token *>::const_iterator it;
|
||||
for (it = _callStack.begin(); it != _callStack.end(); it++)
|
||||
ostr << _tokenizer->fileLine(*it) << " -> ";
|
||||
ostr << errmsg;
|
||||
_errorLogger->reportErr(ostr.str());
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Dangerous functions
|
||||
//---------------------------------------------------------------------------
|
||||
|
|
|
@ -37,15 +37,9 @@ public:
|
|||
|
||||
private:
|
||||
|
||||
/** Report error using the callstack */
|
||||
void ReportError(const std::string &errmsg);
|
||||
|
||||
const Tokenizer *_tokenizer;
|
||||
const Settings _settings;
|
||||
ErrorLogger *_errorLogger;
|
||||
|
||||
/** callstack - used during intra-function checking */
|
||||
std::list<const Token *> _callStack;
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
|
|
@ -315,7 +315,7 @@ void CheckMemoryLeakClass::MemoryLeak(const Token *tok, const char varname[], Al
|
|||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
bool CheckMemoryLeakClass::MatchFunctionsThatReturnArg(const Token *tok, const std::string varname)
|
||||
bool CheckMemoryLeakClass::MatchFunctionsThatReturnArg(const Token *tok, const std::string &varname)
|
||||
{
|
||||
return Token::Match(tok, std::string("; " + varname + " = strcat|memcpy|memmove|strcpy ( " + varname + " ,").c_str());
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ private:
|
|||
*/
|
||||
Token *getcode(const Token *tok, std::list<const Token *> callstack, const char varname[], AllocType &alloctype, AllocType &dealloctype, bool classmember, bool &all);
|
||||
bool notvar(const Token *tok, const char *varnames[]);
|
||||
bool MatchFunctionsThatReturnArg(const Token *tok, const std::string varname);
|
||||
bool MatchFunctionsThatReturnArg(const Token *tok, const std::string &varname);
|
||||
void MemoryLeak(const Token *tok, const char varname[], AllocType alloctype, bool all);
|
||||
void MismatchError(const Token *Tok1, const std::list<const Token *> &callstack, const char varname[]);
|
||||
const char * call_func(const Token *tok, std::list<const Token *> callstack, const char *varnames[], AllocType &alloctype, AllocType &dealloctype, bool &all);
|
||||
|
|
Loading…
Reference in New Issue