From e017d5a07928fba2836dbcfa96d7ca42b3a4634c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 22 Mar 2009 08:20:15 +0100 Subject: [PATCH] refactoring - added 'getErrorMessages' to all check classes --- src/check.h | 3 +-- src/checkautovariables.h | 5 +++++ src/checkbufferoverrun.h | 8 ++++++++ src/checkclass.h | 11 +++++++++++ src/checkdangerousfunctions.h | 6 ++++++ src/checkmemoryleak.h | 15 +++++++++++++++ src/checkother.h | 21 +++++++++++++++++++++ src/checksecurity.h | 5 +++++ 8 files changed, 72 insertions(+), 2 deletions(-) diff --git a/src/check.h b/src/check.h index 0eef58792..12a32b860 100644 --- a/src/check.h +++ b/src/check.h @@ -61,8 +61,7 @@ public: virtual void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) = 0; /** get error messages */ - virtual void getErrorMessages() - { } + virtual void getErrorMessages() = 0; protected: const Tokenizer * const _tokenizer; diff --git a/src/checkautovariables.h b/src/checkautovariables.h index e0ce9e707..88c7b7bab 100644 --- a/src/checkautovariables.h +++ b/src/checkautovariables.h @@ -54,6 +54,11 @@ private: bool error_av(const Token* left, const Token* right); bool is_auto_var(const Token* t); void addVD(const Token* t); + + void getErrorMessages() + { + reportError(0, "error", "autoVariables", "Wrong assignement of an auto-variable to an effective parameter of a function"); + } }; //--------------------------------------------------------------------------- diff --git a/src/checkbufferoverrun.h b/src/checkbufferoverrun.h index 5430bffcd..03cd52d7e 100644 --- a/src/checkbufferoverrun.h +++ b/src/checkbufferoverrun.h @@ -72,6 +72,14 @@ private: void bufferOverrun(const Token *tok); void strncatUsage(const Token *tok); void outOfBounds(const Token *tok, const std::string &what); + + void getErrorMessages() + { + arrayIndexOutOfBounds(0); + bufferOverrun(0); + strncatUsage(0); + outOfBounds(0, "index"); + } }; //--------------------------------------------------------------------------- diff --git a/src/checkclass.h b/src/checkclass.h index c278f71f2..f6b052a72 100644 --- a/src/checkclass.h +++ b/src/checkclass.h @@ -107,6 +107,17 @@ private: void operatorEqError(const Token *tok); void virtualDestructorError(const Token *tok, const std::string &Base, const std::string &Derived); + void getErrorMessages() + { + noConstructorError(0, "classname"); + uninitVarError(0, "classname", "varname"); + unusedPrivateFunctionError(0, "classname", "funcname"); + memsetClassError(0, "memfunc"); + memsetStructError(0, "memfunc", "classname"); + operatorEqError(0); + virtualDestructorError(0, "Base", "Derived"); + } + }; //--------------------------------------------------------------------------- #endif diff --git a/src/checkdangerousfunctions.h b/src/checkdangerousfunctions.h index 4ff505564..45f442949 100644 --- a/src/checkdangerousfunctions.h +++ b/src/checkdangerousfunctions.h @@ -52,6 +52,12 @@ private: void dangerousFunctiongets(const Token *tok); void dangerousFunctionscanf(const Token *tok); + void getErrorMessages() + { + dangerousFunctionmktemp(0); + dangerousFunctiongets(0); + dangerousFunctionscanf(0); + } }; diff --git a/src/checkmemoryleak.h b/src/checkmemoryleak.h index 3e5340f9b..41eb7681a 100644 --- a/src/checkmemoryleak.h +++ b/src/checkmemoryleak.h @@ -133,6 +133,21 @@ private: void mismatchSizeError(const Token *tok, const std::string &sz); void mismatchAllocDealloc(const std::list &callstack, const std::string &varname); + + void getErrorMessages() + { + memleakError(0, "varname"); + memleakallError(0, "varname"); + resourceLeakError(0, "varname"); + deallocDeallocError(0, "varname"); + deallocuseError(0, "varname"); + mismatchSizeError(0, "sz"); + + std::list callstack; + mismatchAllocDealloc(callstack, "varname"); + } + + // Experimental functionality.. protected: Token *functionParameterCode(const Token *ftok, int parameter); diff --git a/src/checkother.h b/src/checkother.h index 24142793f..47015ec0e 100644 --- a/src/checkother.h +++ b/src/checkother.h @@ -132,6 +132,27 @@ private: void strPlusChar(const Token *tok); void returnLocalVariable(const Token *tok); + void getErrorMessages() + { + cstyleCastError(0); + redundantIfDelete0Error(0); + redundantIfRemoveError(0); + dangerousUsageStrtolError(0); + ifNoActionError(0); + sprintfOverlappingDataError(0, "varname"); + udivError(0); + udivWarning(0); + unusedStructMemberError(0, "structname", "varname"); + passedByValueError(0, "parname"); + constStatementError(0, "type"); + charArrayIndexError(0); + charBitOpError(0); + variableScopeError(0, "varname"); + conditionAlwaysTrueFalse(0, "true/false"); + strPlusChar(0); + returnLocalVariable(0); + } + }; //--------------------------------------------------------------------------- diff --git a/src/checksecurity.h b/src/checksecurity.h index 2b6ad5c52..bbf57dc64 100644 --- a/src/checksecurity.h +++ b/src/checksecurity.h @@ -52,6 +52,11 @@ public: private: void unvalidatedInput(const Token *tok); + + void getErrorMessages() + { + unvalidatedInput(0); + } }; //---------------------------------------------------------------------------