From 43722b6067fb727e52d6af44a60703437544e4c2 Mon Sep 17 00:00:00 2001 From: chrchr-github Date: Wed, 26 Jul 2023 13:57:40 +0200 Subject: [PATCH] Use getTokenArgumentFunction() --- lib/checkother.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 2999e546043..22b57edca24 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -1072,15 +1072,11 @@ bool CheckOther::checkInnerScope(const Token *tok, const Variable* var, bool& us return false; // simplified if/for/switch init statement } if (var->isArrayOrPointer()) { - const Token* parent = tok->astParent(); - while (parent && parent->isArithmeticalOp()) - parent = parent->astParent(); - while (Token::simpleMatch(parent, ",")) - parent = parent->astParent(); - if (parent && Token::Match(parent->previous(), "%name% (")) { // var passed to function? - if (parent->previous()->function() && Function::returnsPointer(parent->previous()->function())) + int argn{}; + if (const Token* ftok = getTokenArgumentFunction(tok, argn)) { // var passed to function? + if (ftok->function() && Function::returnsPointer(ftok->function())) return false; - const std::string ret = mSettings->library.returnValueType(parent->previous()); // assume that var is returned + const std::string ret = mSettings->library.returnValueType(ftok); // assume that var is returned if (!ret.empty() && ret.back() == '*') return false; }