Skip to content

Commit 9fdfada

Browse files
committed
Compute value earlier and reuse it
1 parent 7308901 commit 9fdfada

1 file changed

Lines changed: 7 additions & 11 deletions

File tree

lib/checkio.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -202,20 +202,16 @@ void CheckIO::checkFileUsage()
202202
operation = Filepointer::OPEN;
203203
} else if ((tok->str() == "rewind" || tok->str() == "fseek" || tok->str() == "fsetpos" || tok->str() == "fflush") ||
204204
(windows && tok->str() == "_fseeki64")) {
205-
if (printPortability && tok->str() == "fflush") {
206-
fileTok = tok->tokAt(2);
207-
if (fileTok) {
208-
if (fileTok->str() == "stdin")
205+
fileTok = tok->tokAt(2);
206+
if (printPortability && fileTok && tok->str() == "fflush") {
207+
if (fileTok->str() == "stdin")
208+
fflushOnInputStreamError(tok, fileTok->str());
209+
else {
210+
Filepointer& f = filepointers[fileTok->varId()];
211+
if (f.mode == READ_MODE)
209212
fflushOnInputStreamError(tok, fileTok->str());
210-
else {
211-
Filepointer& f = filepointers[fileTok->varId()];
212-
if (f.mode == READ_MODE)
213-
fflushOnInputStreamError(tok, fileTok->str());
214-
}
215213
}
216214
}
217-
218-
fileTok = tok->tokAt(2);
219215
operation = Filepointer::POSITIONING;
220216
} else if (tok->str() == "fgetc" || tok->str() == "fgetwc" ||
221217
tok->str() == "fgets" || tok->str() == "fgetws" || tok->str() == "fread" ||

0 commit comments

Comments
 (0)