Skip to content

Commit fd01caf

Browse files
committed
Clean up redundant pointer operations
1 parent e6f042d commit fd01caf

File tree

5 files changed

+19
-19
lines changed

5 files changed

+19
-19
lines changed

lib/checkbufferoverrun.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,12 +1220,12 @@ void CheckBufferOverrun::checkStructVariable()
12201220
// If struct is declared in a function then check
12211221
// if scope_func matches
12221222
if (scope->nestedIn->type == Scope::eFunction &&
1223-
scope->nestedIn != &*func_scope) {
1223+
scope->nestedIn != func_scope) {
12241224
continue;
12251225
}
12261226

12271227
// check for member variables
1228-
if (func_scope->functionOf == &*scope) {
1228+
if (func_scope->functionOf == scope) {
12291229
// only check non-empty function
12301230
if (func_scope->classStart->next() != func_scope->classEnd) {
12311231
// start checking after the {

lib/checkclass.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ void CheckClass::constructors()
128128
clearAllVar(usage);
129129

130130
std::list<const Function *> callstack;
131-
initializeVarList(*func, callstack, &(*scope), usage);
131+
initializeVarList(*func, callstack, scope, usage);
132132

133133
// Check if any variables are uninitialized
134134
std::list<Variable>::const_iterator var;
@@ -233,14 +233,14 @@ void CheckClass::copyconstructors()
233233
for (const Token* const end = func->functionScope->classStart; tok != end; tok = tok->next()) {
234234
if (Token::Match(tok, "%var% ( new|malloc|g_malloc|g_try_malloc|realloc|g_realloc|g_try_realloc")) {
235235
const Variable* var = tok->variable();
236-
if (var && var->isPointer() && var->scope() == &*scope)
236+
if (var && var->isPointer() && var->scope() == scope)
237237
allocatedVars[tok->varId()] = tok;
238238
}
239239
}
240240
for (const Token* const end = func->functionScope->classEnd; tok != end; tok = tok->next()) {
241241
if (Token::Match(tok, "%var% = new|malloc|g_malloc|g_try_malloc|realloc|g_realloc|g_try_realloc")) {
242242
const Variable* var = tok->variable();
243-
if (var && var->isPointer() && var->scope() == &*scope)
243+
if (var && var->isPointer() && var->scope() == scope)
244244
allocatedVars[tok->varId()] = tok;
245245
}
246246
}
@@ -882,7 +882,7 @@ void CheckClass::privateFunctions()
882882
while (!privateFuncs.empty()) {
883883
const std::string& funcName = privateFuncs.front()->tokenDef->str();
884884
// Check that all private functions are used
885-
bool used = checkFunctionUsage(funcName, &*scope); // Usage in this class
885+
bool used = checkFunctionUsage(funcName, scope); // Usage in this class
886886
// Check in friend classes
887887
const std::list<Type::FriendInfo>& friendList = scope->definedType->friendList;
888888
for (std::list<Type::FriendInfo>::const_iterator it = friendList.begin(); !used && it != friendList.end(); ++it) {
@@ -981,18 +981,18 @@ void CheckClass::checkMemset()
981981
typeTok = typeTok->next();
982982

983983
if (!type) {
984-
const Type* t = symbolDatabase->findVariableType(&(*scope), typeTok);
984+
const Type* t = symbolDatabase->findVariableType(scope, typeTok);
985985
if (t)
986986
type = t->classScope;
987987
}
988988

989989
if (type) {
990990
std::list<const Scope *> parsedTypes;
991-
checkMemsetType(&(*scope), tok, type, false, parsedTypes);
991+
checkMemsetType(scope, tok, type, false, parsedTypes);
992992
}
993993
} else if (tok->variable() && tok->variable()->typeScope() && Token::Match(tok, "%var% = calloc|malloc|realloc|g_malloc|g_try_malloc|g_realloc|g_try_realloc (")) {
994994
std::list<const Scope *> parsedTypes;
995-
checkMemsetType(&(*scope), tok->tokAt(2), tok->variable()->typeScope(), true, parsedTypes);
995+
checkMemsetType(scope, tok->tokAt(2), tok->variable()->typeScope(), true, parsedTypes);
996996

997997
if (tok->variable()->typeScope()->numConstructors > 0 && _settings->isEnabled("warning"))
998998
mallocOnClassWarning(tok, tok->strAt(2), tok->variable()->typeScope()->classDef);
@@ -1163,7 +1163,7 @@ void CheckClass::operatorEqRetRefThis()
11631163
if (func->type == Function::eOperatorEqual && func->hasBody()) {
11641164
// make sure return signature is correct
11651165
if (Token::Match(func->retDef, "%type% &") && func->retDef->str() == scope->className) {
1166-
checkReturnPtrThis(&(*scope), &(*func), func->functionScope->classStart, func->functionScope->classEnd);
1166+
checkReturnPtrThis(scope, &(*func), func->functionScope->classStart, func->functionScope->classEnd);
11671167
}
11681168
}
11691169
}
@@ -1281,7 +1281,7 @@ void CheckClass::operatorEqToSelf()
12811281
const Token *rhs = func->argumentList.begin()->nameToken();
12821282

12831283
if (!hasAssignSelf(&(*func), rhs)) {
1284-
if (hasAllocation(&(*func), &*scope))
1284+
if (hasAllocation(&(*func), scope))
12851285
operatorEqToSelfError(func->token);
12861286
}
12871287
}
@@ -1605,7 +1605,7 @@ void CheckClass::checkConst()
16051605

16061606
bool memberAccessed = false;
16071607
// if nothing non-const was found. write error..
1608-
if (checkConstFunc(&(*scope), &*func, memberAccessed)) {
1608+
if (checkConstFunc(scope, &*func, memberAccessed)) {
16091609
std::string classname = scope->className;
16101610
const Scope *nest = scope->nestedIn;
16111611
while (nest && nest->type != Scope::eGlobal) {

lib/checkmemoryleak.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2278,19 +2278,19 @@ void CheckMemoryLeakInClass::check()
22782278
const Token *tok = var->typeStartToken();
22792279
if (tok->isStandardType()) {
22802280
if (var->isPrivate())
2281-
checkPublicFunctions(&(*scope), var->nameToken());
2281+
checkPublicFunctions(scope, var->nameToken());
22822282

2283-
variable(&(*scope), var->nameToken());
2283+
variable(scope, var->nameToken());
22842284
}
22852285

22862286
// known class?
22872287
else if (var->type()) {
22882288
// not derived?
22892289
if (var->type()->derivedFrom.empty()) {
22902290
if (var->isPrivate())
2291-
checkPublicFunctions(&(*scope), var->nameToken());
2291+
checkPublicFunctions(scope, var->nameToken());
22922292

2293-
variable(&(*scope), var->nameToken());
2293+
variable(scope, var->nameToken());
22942294
}
22952295
}
22962296
}

lib/checkunusedvar.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1087,7 +1087,7 @@ void CheckUnusedVar::checkFunctionVariableUsage()
10871087
// varId, usage {read, write, modified}
10881088
Variables variables;
10891089

1090-
checkFunctionVariableUsage_iterateScopes(&*scope, variables, false);
1090+
checkFunctionVariableUsage_iterateScopes(scope, variables, false);
10911091

10921092

10931093
// Check usage of all variables in the current scope..

lib/symboldatabase.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1680,7 +1680,7 @@ void SymbolDatabase::addClassFunction(Scope **scope, const Token **tok, const To
16801680
addNewFunction(scope, tok);
16811681
if (*scope) {
16821682
(*scope)->functionOf = func->nestedIn;
1683-
(*scope)->function = &*func;
1683+
(*scope)->function = func;
16841684
(*scope)->function->functionScope = *scope;
16851685
}
16861686
return;
@@ -1751,7 +1751,7 @@ void SymbolDatabase::addClassFunction(Scope **scope, const Token **tok, const To
17511751
addNewFunction(scope, tok);
17521752
if (*scope) {
17531753
(*scope)->functionOf = scope1;
1754-
(*scope)->function = &*func;
1754+
(*scope)->function = func;
17551755
(*scope)->function->functionScope = *scope;
17561756
}
17571757
return;

0 commit comments

Comments
 (0)