Skip to content

Commit

Permalink
Fix selfcheck warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Nov 21, 2023
1 parent 309663f commit 3ddd8a9
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion cli/cppcheckexecutorsig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ static void CppcheckSignalHandler(int signo, siginfo_t * info, void * context)
}
}

int check_wrapper_sig(CppCheckExecutor& executor, int (CppCheckExecutor::*f)(CppCheck&), CppCheck& cppcheck)
int check_wrapper_sig(const CppCheckExecutor& executor, int (CppCheckExecutor::*f)(CppCheck&), const CppCheck& cppcheck)
{
// determine stack vs. heap
char stackVariable;
Expand Down
2 changes: 1 addition & 1 deletion cli/cppcheckexecutorsig.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
class CppCheckExecutor;
class CppCheck;

int check_wrapper_sig(CppCheckExecutor& executor, int (CppCheckExecutor::*f)(CppCheck&), CppCheck& cppcheck);
int check_wrapper_sig(const CppCheckExecutor& executor, int (CppCheckExecutor::*f)(CppCheck&), const CppCheck& cppcheck);

#endif // CPPCHECKEXECUTORSIG_H

Expand Down
2 changes: 2 additions & 0 deletions lib/checkother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1390,6 +1390,8 @@ void CheckOther::checkConstVariable()
continue;
if (var->isVolatile())
continue;
if (var->nameToken()->isExpandedMacro())
continue;
if (isStructuredBindingVariable(var)) // TODO: check all bound variables
continue;
if (isVariableChanged(var, mSettings, mTokenizer->isCPP()))
Expand Down
9 changes: 3 additions & 6 deletions lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ namespace {
bool mUsed = false;

public:
TypedefSimplifier(Token* typedefToken, int &num) : mTypedefToken(typedefToken) {
explicit TypedefSimplifier(Token* typedefToken) : mTypedefToken(typedefToken) {
Token* start = typedefToken->next();
if (Token::simpleMatch(start, "typename"))
start = start->next();
Expand All @@ -641,7 +641,6 @@ namespace {
mRangeTypeQualifiers = rangeQualifiers;
Token* typeName = rangeBefore.second->previous();
if (typeName->isKeyword()) {
(void)num;
// TODO typeName->insertToken("T:" + std::to_string(num++));
typeName->insertToken(nameToken->str());
}
Expand Down Expand Up @@ -1048,16 +1047,14 @@ void Tokenizer::simplifyTypedef()
std::map<std::string, int> numberOfTypedefs;
for (Token* tok = list.front(); tok; tok = tok->next()) {
if (tok->str() == "typedef") {
int dummy = 0;
TypedefSimplifier ts(tok, dummy);
TypedefSimplifier ts(tok);
if (!ts.fail())
numberOfTypedefs[ts.name()]++;
continue;
}
}

int indentlevel = 0;
int typeNum = 1;
std::map<std::string, TypedefSimplifier> typedefs;
for (Token* tok = list.front(); tok; tok = tok->next()) {
if (!tok->isName()) {
Expand All @@ -1069,7 +1066,7 @@ void Tokenizer::simplifyTypedef()
}

if (indentlevel == 0 && tok->str() == "typedef") {
TypedefSimplifier ts(tok, typeNum);
TypedefSimplifier ts(tok);
if (!ts.fail() && numberOfTypedefs[ts.name()] == 1) {
if (mSettings->severity.isEnabled(Severity::portability) && ts.isInvalidConstFunctionType(typedefs))
reportError(tok->next(), Severity::portability, "invalidConstFunctionType",
Expand Down
6 changes: 3 additions & 3 deletions lib/valueflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5238,7 +5238,7 @@ static const Scope* getLoopScope(const Token* tok)
}

//
static void valueFlowConditionExpressions(TokenList &tokenlist, const SymbolDatabase& symboldatabase, ErrorLogger *errorLogger, const Settings &settings)
static void valueFlowConditionExpressions(const TokenList &tokenlist, const SymbolDatabase& symboldatabase, ErrorLogger *errorLogger, const Settings &settings)
{
for (const Scope * scope : symboldatabase.functionScopes) {
if (const Token* incompleteTok = findIncompleteVar(scope->bodyStart, scope->bodyEnd)) {
Expand Down Expand Up @@ -7482,7 +7482,7 @@ static void valueFlowInjectParameter(const TokenList& tokenlist,
settings);
}

static void valueFlowSwitchVariable(TokenList &tokenlist, const SymbolDatabase& symboldatabase, ErrorLogger *errorLogger, const Settings *settings)
static void valueFlowSwitchVariable(const TokenList &tokenlist, const SymbolDatabase& symboldatabase, ErrorLogger *errorLogger, const Settings *settings)
{
for (const Scope &scope : symboldatabase.scopeList) {
if (scope.type != Scope::ScopeType::eSwitch)
Expand Down Expand Up @@ -9408,7 +9408,7 @@ static ValueFlowPassAdaptor<F> makeValueFlowPassAdaptor(const char* name, bool c
#define VALUEFLOW_ADAPTOR(cpp, ...) \
makeValueFlowPassAdaptor(#__VA_ARGS__, \
cpp, \
[](TokenList& tokenlist, \
[](TokenList& tokenlist, /* cppcheck-suppress constVariable*/ \
SymbolDatabase& symboldatabase, \
ErrorLogger* errorLogger, \
const Settings* settings, \
Expand Down

0 comments on commit 3ddd8a9

Please sign in to comment.