Skip to content

Commit 13c1509

Browse files
fixup! fixup! fixup! fixup! Fix #958: warn when feof() is used as a while loop condition
1 parent 5523c33 commit 13c1509

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

lib/checkio.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -488,11 +488,10 @@ static bool findFileReadCall(const Token *start, const Token *end, int varid)
488488
if (args.empty())
489489
return false;
490490

491-
if (found->str() == "fscanf") {
491+
if (found->str() == "fscanf")
492492
return args.front()->varId() == varid;
493-
} else {
494-
return args.back()->varId() == varid;
495-
}
493+
494+
return args.back()->varId() == varid;
496495
}
497496

498497
void CheckIO::checkWrongfeofUsage()
@@ -503,7 +502,7 @@ void CheckIO::checkWrongfeofUsage()
503502

504503
for (const Scope * scope : symbolDatabase->functionScopes) {
505504
for (const Token *tok = scope->bodyStart->next(); tok != scope->bodyEnd; tok = tok->next()) {
506-
if (!Token::Match(tok, "while ( ! feof ("))
505+
if (!Token::simpleMatch(tok, "while ( ! feof ("))
507506
continue;
508507

509508
// Usage of feof is correct if a read happens before and within the loop

0 commit comments

Comments
 (0)