Fixed #2433 (strtol: false positive when strtol isn't used in function call)
This commit is contained in:
parent
d27b6a1598
commit
d758929490
|
@ -338,19 +338,18 @@ void CheckOther::invalidFunctionUsage()
|
||||||
// strtol and strtoul..
|
// strtol and strtoul..
|
||||||
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next())
|
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next())
|
||||||
{
|
{
|
||||||
if ((tok->str() != "strtol") && (tok->str() != "strtoul"))
|
if (!Token::Match(tok, "strtol|strtoul ("))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Locate the third parameter of the function call..
|
// Locate the third parameter of the function call..
|
||||||
int parlevel = 0;
|
|
||||||
int param = 1;
|
int param = 1;
|
||||||
for (const Token *tok2 = tok->next(); tok2; tok2 = tok2->next())
|
for (const Token *tok2 = tok->tokAt(2); tok2; tok2 = tok2->next())
|
||||||
{
|
{
|
||||||
if (tok2->str() == "(")
|
if (tok2->str() == "(")
|
||||||
++parlevel;
|
tok2 = tok2->link();
|
||||||
else if (tok2->str() == ")")
|
else if (tok2->str() == ")")
|
||||||
--parlevel;
|
break;
|
||||||
else if (parlevel == 1 && tok2->str() == ",")
|
else if (tok2->str() == ",")
|
||||||
{
|
{
|
||||||
++param;
|
++param;
|
||||||
if (param == 3)
|
if (param == 3)
|
||||||
|
|
Loading…
Reference in New Issue