switch some functions from const to static, as cppcheck suggests.

This commit is contained in:
Matthias Krüger 2017-02-27 13:22:10 +01:00
parent 900d05d9dd
commit 35e7697474
6 changed files with 11 additions and 12 deletions

View File

@ -349,7 +349,6 @@ void CheckIO::ioWithoutPositioningError(const Token *tok)
void CheckIO::readWriteOnlyFileError(const Token *tok)
{
reportError(tok, Severity::error,
"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);
}
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;
}

View File

@ -128,7 +128,7 @@ private:
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);
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 {
CheckIO c(nullptr, settings, errorLogger);

View File

@ -34,13 +34,13 @@ namespace cppcheck {
*/
class CPPCHECKLIB Platform {
private:
long long min_value(int bit) const {
static long long min_value(int bit) {
if (bit >= 64)
return 1LL << 63;
return -(1LL << (bit-1));
}
long long max_value(int bit) const {
static long long max_value(int bit) {
if (bit >= 64)
return (~0ULL) >> 1;
return (1LL << (bit-1)) - 1LL;

View File

@ -100,12 +100,12 @@ public:
bool verbose;
/** @brief Request termination of checking */
void terminate(bool t = true) {
static void terminate(bool t = true) {
Settings::_terminated = t;
}
/** @brief termination requested? */
bool terminated() const {
static bool terminated() {
return Settings::_terminated;
}

View File

@ -7194,7 +7194,7 @@ void Tokenizer::simplifyNestedStrcat()
// Check if this statement is a duplicate definition. A duplicate
// definition will hide the enumerator within it's scope so just
// skip the entire scope of the duplicate.
bool Tokenizer::duplicateDefinition(Token ** tokPtr) const
bool Tokenizer::duplicateDefinition(Token ** tokPtr)
{
// check for an end of definition
const Token * tok = *tokPtr;
@ -8068,7 +8068,7 @@ const Token * Tokenizer::findGarbageCode() const
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;
controlFlowKeywords.insert("goto");

View File

@ -582,7 +582,7 @@ private:
const Token * findGarbageCode() const;
/** Detect garbage expression */
bool isGarbageExpr(const Token *start, const Token *end) const;
static bool isGarbageExpr(const Token *start, const Token *end);
/**
* Remove __declspec()
@ -679,7 +679,7 @@ private:
/**
* check for duplicate enum definition
*/
bool duplicateDefinition(Token **tokPtr) const;
static bool duplicateDefinition(Token **tokPtr);
/**
* report error message
@ -794,7 +794,7 @@ public:
*/
static const Token * startOfExecutableScope(const Token * tok);
bool isMaxTime() const {
static bool isMaxTime() {
#ifdef MAXTIME
return (std::time(0) > maxtime);
#else