Skip to content

Commit 7308901

Browse files
committed
Omit duplicate and opposite checks
1 parent a1df585 commit 7308901

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

lib/checkio.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -525,14 +525,16 @@ void CheckIO::checkWrongPrintfScanfArguments()
525525
// formatstring found in library. Find format string and first argument belonging to format string.
526526
if (!findFormat(static_cast<unsigned int>(formatStringArgNo), tok->tokAt(2), &formatStringTok, &argListTok))
527527
continue;
528-
} else if (Token::simpleMatch(tok, "swprintf (") && Token::Match(tok->tokAt(2)->nextArgument(), "%str%")) {
529-
// Find third parameter and format string
530-
if (!findFormat(1, tok->tokAt(2), &formatStringTok, &argListTok))
531-
continue;
532-
} else if (Token::simpleMatch(tok, "swprintf (") && !Token::Match(tok->tokAt(2)->nextArgument(), "%str%")) {
533-
// Find fourth parameter and format string
534-
if (!findFormat(2, tok->tokAt(2), &formatStringTok, &argListTok))
535-
continue;
528+
} else if (Token::simpleMatch(tok, "swprintf (")) {
529+
if (Token::Match(tok->tokAt(2)->nextArgument(), "%str%")) {
530+
// Find third parameter and format string
531+
if (!findFormat(1, tok->tokAt(2), &formatStringTok, &argListTok))
532+
continue;
533+
} else {
534+
// Find fourth parameter and format string
535+
if (!findFormat(2, tok->tokAt(2), &formatStringTok, &argListTok))
536+
continue;
537+
}
536538
} else if (isWindows && Token::Match(tok, "sprintf_s|swprintf_s (")) {
537539
// template <size_t size> int sprintf_s(char (&buffer)[size], const char *format, ...);
538540
if (findFormat(1, tok->tokAt(2), &formatStringTok, &argListTok)) {

0 commit comments

Comments
 (0)