switch some functions from const to static, as cppcheck suggests.
This commit is contained in:
parent
900d05d9dd
commit
35e7697474
|
@ -349,7 +349,6 @@ void CheckIO::ioWithoutPositioningError(const Token *tok)
|
||||||
|
|
||||||
void CheckIO::readWriteOnlyFileError(const Token *tok)
|
void CheckIO::readWriteOnlyFileError(const Token *tok)
|
||||||
{
|
{
|
||||||
|
|
||||||
reportError(tok, Severity::error,
|
reportError(tok, Severity::error,
|
||||||
"readWriteOnlyFile", "Read operation on a file that was opened only for writing.", CWE664, false);
|
"readWriteOnlyFile", "Read operation on a file that was opened only for writing.", CWE664, false);
|
||||||
}
|
}
|
||||||
|
@ -2001,7 +2000,7 @@ void CheckIO::invalidPrintfArgTypeError_float(const Token* tok, unsigned int num
|
||||||
reportError(tok, severity, "invalidPrintfArgType_float", errmsg.str(), CWE686, false);
|
reportError(tok, severity, "invalidPrintfArgType_float", errmsg.str(), CWE686, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
Severity::SeverityType CheckIO::getSeverity(const CheckIO::ArgumentInfo *argInfo) const
|
Severity::SeverityType CheckIO::getSeverity(const CheckIO::ArgumentInfo *argInfo)
|
||||||
{
|
{
|
||||||
return (argInfo && argInfo->typeToken && !argInfo->typeToken->originalName().empty()) ? Severity::portability : Severity::warning;
|
return (argInfo && argInfo->typeToken && !argInfo->typeToken->originalName().empty()) ? Severity::portability : Severity::warning;
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,7 +128,7 @@ private:
|
||||||
void invalidLengthModifierError(const Token* tok, unsigned int numFormat, const std::string& modifier);
|
void invalidLengthModifierError(const Token* tok, unsigned int numFormat, const std::string& modifier);
|
||||||
void invalidScanfFormatWidthError(const Token* tok, unsigned int numFormat, int width, const Variable *var, char c);
|
void invalidScanfFormatWidthError(const Token* tok, unsigned int numFormat, int width, const Variable *var, char c);
|
||||||
static void argumentType(std::ostream & s, const ArgumentInfo * argInfo);
|
static void argumentType(std::ostream & s, const ArgumentInfo * argInfo);
|
||||||
Severity::SeverityType getSeverity(const ArgumentInfo *argInfo) const;
|
static Severity::SeverityType getSeverity(const ArgumentInfo *argInfo);
|
||||||
|
|
||||||
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const {
|
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const {
|
||||||
CheckIO c(nullptr, settings, errorLogger);
|
CheckIO c(nullptr, settings, errorLogger);
|
||||||
|
|
|
@ -34,13 +34,13 @@ namespace cppcheck {
|
||||||
*/
|
*/
|
||||||
class CPPCHECKLIB Platform {
|
class CPPCHECKLIB Platform {
|
||||||
private:
|
private:
|
||||||
long long min_value(int bit) const {
|
static long long min_value(int bit) {
|
||||||
if (bit >= 64)
|
if (bit >= 64)
|
||||||
return 1LL << 63;
|
return 1LL << 63;
|
||||||
return -(1LL << (bit-1));
|
return -(1LL << (bit-1));
|
||||||
}
|
}
|
||||||
|
|
||||||
long long max_value(int bit) const {
|
static long long max_value(int bit) {
|
||||||
if (bit >= 64)
|
if (bit >= 64)
|
||||||
return (~0ULL) >> 1;
|
return (~0ULL) >> 1;
|
||||||
return (1LL << (bit-1)) - 1LL;
|
return (1LL << (bit-1)) - 1LL;
|
||||||
|
|
|
@ -100,12 +100,12 @@ public:
|
||||||
bool verbose;
|
bool verbose;
|
||||||
|
|
||||||
/** @brief Request termination of checking */
|
/** @brief Request termination of checking */
|
||||||
void terminate(bool t = true) {
|
static void terminate(bool t = true) {
|
||||||
Settings::_terminated = t;
|
Settings::_terminated = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @brief termination requested? */
|
/** @brief termination requested? */
|
||||||
bool terminated() const {
|
static bool terminated() {
|
||||||
return Settings::_terminated;
|
return Settings::_terminated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7194,7 +7194,7 @@ void Tokenizer::simplifyNestedStrcat()
|
||||||
// Check if this statement is a duplicate definition. A duplicate
|
// Check if this statement is a duplicate definition. A duplicate
|
||||||
// definition will hide the enumerator within it's scope so just
|
// definition will hide the enumerator within it's scope so just
|
||||||
// skip the entire scope of the duplicate.
|
// skip the entire scope of the duplicate.
|
||||||
bool Tokenizer::duplicateDefinition(Token ** tokPtr) const
|
bool Tokenizer::duplicateDefinition(Token ** tokPtr)
|
||||||
{
|
{
|
||||||
// check for an end of definition
|
// check for an end of definition
|
||||||
const Token * tok = *tokPtr;
|
const Token * tok = *tokPtr;
|
||||||
|
@ -8068,7 +8068,7 @@ const Token * Tokenizer::findGarbageCode() const
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Tokenizer::isGarbageExpr(const Token *start, const Token *end) const
|
bool Tokenizer::isGarbageExpr(const Token *start, const Token *end)
|
||||||
{
|
{
|
||||||
std::set<std::string> controlFlowKeywords;
|
std::set<std::string> controlFlowKeywords;
|
||||||
controlFlowKeywords.insert("goto");
|
controlFlowKeywords.insert("goto");
|
||||||
|
|
|
@ -582,7 +582,7 @@ private:
|
||||||
const Token * findGarbageCode() const;
|
const Token * findGarbageCode() const;
|
||||||
|
|
||||||
/** Detect garbage expression */
|
/** Detect garbage expression */
|
||||||
bool isGarbageExpr(const Token *start, const Token *end) const;
|
static bool isGarbageExpr(const Token *start, const Token *end);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove __declspec()
|
* Remove __declspec()
|
||||||
|
@ -679,7 +679,7 @@ private:
|
||||||
/**
|
/**
|
||||||
* check for duplicate enum definition
|
* check for duplicate enum definition
|
||||||
*/
|
*/
|
||||||
bool duplicateDefinition(Token **tokPtr) const;
|
static bool duplicateDefinition(Token **tokPtr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* report error message
|
* report error message
|
||||||
|
@ -794,7 +794,7 @@ public:
|
||||||
*/
|
*/
|
||||||
static const Token * startOfExecutableScope(const Token * tok);
|
static const Token * startOfExecutableScope(const Token * tok);
|
||||||
|
|
||||||
bool isMaxTime() const {
|
static bool isMaxTime() {
|
||||||
#ifdef MAXTIME
|
#ifdef MAXTIME
|
||||||
return (std::time(0) > maxtime);
|
return (std::time(0) > maxtime);
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Reference in New Issue