Merge branch 'master' of git@github.com:danmar/cppcheck

This commit is contained in:
Kimmo Varis 2009-07-13 18:54:10 +03:00
commit 5b33071ec0
6 changed files with 29 additions and 29 deletions

View File

@ -38,39 +38,39 @@
// Register this check class (by creating a static instance of it)
namespace
{
CheckBufferOverrunClass instance;
CheckBufferOverrun instance;
}
//---------------------------------------------------------------------------
void CheckBufferOverrunClass::arrayIndexOutOfBounds(const Token *tok)
void CheckBufferOverrun::arrayIndexOutOfBounds(const Token *tok)
{
_callStack.push_back(tok);
arrayIndexOutOfBounds();
_callStack.pop_back();
}
void CheckBufferOverrunClass::arrayIndexOutOfBounds()
void CheckBufferOverrun::arrayIndexOutOfBounds()
{
reportError(_callStack, Severity::possibleError, "arrayIndexOutOfBounds", "Array index out of bounds");
}
void CheckBufferOverrunClass::bufferOverrun(const Token *tok)
void CheckBufferOverrun::bufferOverrun(const Token *tok)
{
reportError(tok, Severity::possibleError, "bufferOverrun", "Buffer overrun");
}
void CheckBufferOverrunClass::strncatUsage(const Token *tok)
void CheckBufferOverrun::strncatUsage(const Token *tok)
{
reportError(tok, Severity::possibleError, "strncatUsage", "Dangerous usage of strncat. Tip: the 3rd parameter means maximum number of characters to append");
}
void CheckBufferOverrunClass::outOfBounds(const Token *tok, const std::string &what)
void CheckBufferOverrun::outOfBounds(const Token *tok, const std::string &what)
{
reportError(tok, Severity::error, "outOfBounds", what + " is out of bounds");
}
void CheckBufferOverrunClass::sizeArgumentAsChar(const Token *tok)
void CheckBufferOverrun::sizeArgumentAsChar(const Token *tok)
{
reportError(tok, Severity::possibleError, "sizeArgumentAsChar", "The size argument is given as a char constant");
}
@ -82,7 +82,7 @@ void CheckBufferOverrunClass::sizeArgumentAsChar(const Token *tok)
// Check array usage..
//---------------------------------------------------------------------------
void CheckBufferOverrunClass::checkScope(const Token *tok, const char *varname[], const int size, const int total_size, unsigned int varid)
void CheckBufferOverrun::checkScope(const Token *tok, const char *varname[], const int size, const int total_size, unsigned int varid)
{
unsigned int varc = 0;
@ -440,7 +440,7 @@ void CheckBufferOverrunClass::checkScope(const Token *tok, const char *varname[]
// Checking local variables in a scope
//---------------------------------------------------------------------------
void CheckBufferOverrunClass::checkGlobalAndLocalVariable()
void CheckBufferOverrun::checkGlobalAndLocalVariable()
{
int indentlevel = 0;
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next())
@ -509,7 +509,7 @@ void CheckBufferOverrunClass::checkGlobalAndLocalVariable()
// Checking member variables of structs..
//---------------------------------------------------------------------------
void CheckBufferOverrunClass::checkStructVariable()
void CheckBufferOverrun::checkStructVariable()
{
const char declstruct[] = "struct|class %var% {";
for (const Token *tok = Token::findmatch(_tokenizer->tokens(), declstruct);
@ -622,7 +622,7 @@ void CheckBufferOverrunClass::checkStructVariable()
}
//---------------------------------------------------------------------------
void CheckBufferOverrunClass::bufferOverrun()
void CheckBufferOverrun::bufferOverrun()
{
checkGlobalAndLocalVariable();
checkStructVariable();

View File

@ -30,24 +30,24 @@ class ErrorLogger;
class Token;
class Tokenizer;
class CheckBufferOverrunClass : public Check
class CheckBufferOverrun : public Check
{
public:
/** This constructor is used when registering the CheckClass */
CheckBufferOverrunClass() : Check()
CheckBufferOverrun() : Check()
{ }
/** This constructor is used when running checks.. */
CheckBufferOverrunClass(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
CheckBufferOverrun(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
: Check(tokenizer, settings, errorLogger)
{ }
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
{
CheckBufferOverrunClass checkBufferOverrunClass(tokenizer, settings, errorLogger);
CheckBufferOverrun checkBufferOverrun(tokenizer, settings, errorLogger);
if (settings->_showAll)
checkBufferOverrunClass.bufferOverrun();
checkBufferOverrun.bufferOverrun();
}
/** Check for buffer overruns */

View File

@ -28,10 +28,10 @@
// Register this check class (by creating a static instance of it)
namespace
{
CheckDangerousFunctionsClass instance;
CheckDangerousFunctions instance;
}
void CheckDangerousFunctionsClass::dangerousFunctions()
void CheckDangerousFunctions::dangerousFunctions()
{
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next())
{
@ -52,17 +52,17 @@ void CheckDangerousFunctionsClass::dangerousFunctions()
//---------------------------------------------------------------------------
void CheckDangerousFunctionsClass::dangerousFunctionmktemp(const Token *tok)
void CheckDangerousFunctions::dangerousFunctionmktemp(const Token *tok)
{
reportError(tok, Severity::style, "dangerousFunctionmktemp", "Found 'mktemp'. You should use 'mkstemp' instead");
}
void CheckDangerousFunctionsClass::dangerousFunctiongets(const Token *tok)
void CheckDangerousFunctions::dangerousFunctiongets(const Token *tok)
{
reportError(tok, Severity::style, "dangerousFunctiongets", "Found 'gets'. You should use 'fgets' instead");
}
void CheckDangerousFunctionsClass::dangerousFunctionscanf(const Token *tok)
void CheckDangerousFunctions::dangerousFunctionscanf(const Token *tok)
{
reportError(tok, Severity::style, "dangerousFunctionscanf", "Found 'scanf'. You should use 'fgets' instead");
}

View File

@ -24,24 +24,24 @@
#include "check.h"
class CheckDangerousFunctionsClass : public Check
class CheckDangerousFunctions : public Check
{
public:
/** This constructor is used when registering the CheckClass */
CheckDangerousFunctionsClass() : Check()
/** This constructor is used when registering the CheckDangerousFunctions */
CheckDangerousFunctions() : Check()
{ }
/** This constructor is used when running checks.. */
CheckDangerousFunctionsClass(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
CheckDangerousFunctions(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
: Check(tokenizer, settings, errorLogger)
{ }
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
{
CheckDangerousFunctionsClass checkDangerousFunctionsClass(tokenizer, settings, errorLogger);
CheckDangerousFunctions checkDangerousFunctions(tokenizer, settings, errorLogger);
if (settings->_checkCodingStyle)
{
checkDangerousFunctionsClass.dangerousFunctions();
checkDangerousFunctions.dangerousFunctions();
}
}

View File

@ -55,7 +55,7 @@ private:
// Check for buffer overruns..
Settings settings;
settings._showAll = true;
CheckBufferOverrunClass checkBufferOverrun(&tokenizer, &settings, this);
CheckBufferOverrun checkBufferOverrun(&tokenizer, &settings, this);
checkBufferOverrun.bufferOverrun();
}

View File

@ -55,7 +55,7 @@ private:
// Check for dangerous functions..
Settings settings;
settings._showAll = true;
CheckDangerousFunctionsClass checkDangerousFunctions(&tokenizer, &settings, this);
CheckDangerousFunctions checkDangerousFunctions(&tokenizer, &settings, this);
checkDangerousFunctions.dangerousFunctions();
}