diff --git a/lib/checkio.cpp b/lib/checkio.cpp index be50a8351..4bd42c5ae 100644 --- a/lib/checkio.cpp +++ b/lib/checkio.cpp @@ -470,12 +470,9 @@ void CheckIO::checkWrongPrintfScanfArguments() } } else if (Token::Match(tok, "sprintf|fprintf|sscanf|fscanf|swscanf|fwprintf|fwscanf ( %any%") || (Token::simpleMatch(tok, "swprintf (") && Token::Match(tok->tokAt(2)->nextArgument(), "%str%"))) { const Token* formatStringTok = tok->tokAt(2)->nextArgument(); // Find second parameter (format string) - if (Token::Match(formatStringTok, "%str% ,")) { + if (Token::Match(formatStringTok, "%str% [,)]")) { argListTok = formatStringTok->nextArgument(); // Find third parameter (first argument of va_args) formatString = formatStringTok->str(); - } else if (Token::Match(formatStringTok, "%str% )")) { - argListTok = 0; // Find third parameter (first argument of va_args) - formatString = formatStringTok->str(); } else { continue; } @@ -484,12 +481,9 @@ void CheckIO::checkWrongPrintfScanfArguments() for (int i = 0; i < 2 && formatStringTok; i++) { formatStringTok = formatStringTok->nextArgument(); // Find third parameter (format string) } - if (Token::Match(formatStringTok, "%str% ,")) { + if (Token::Match(formatStringTok, "%str% [,)]")) { argListTok = formatStringTok->nextArgument(); // Find fourth parameter (first argument of va_args) formatString = formatStringTok->str(); - } else if (Token::Match(formatStringTok, "%str% )")) { - argListTok = 0; // Find fourth parameter (first argument of va_args) - formatString = formatStringTok->str(); } else { continue; }