From 1849489315fc6ee8bc08c4bd0e1a0031459117e3 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Fri, 8 Sep 2023 01:30:26 +0300 Subject: [PATCH] QFSFileEngine: fix logic Inside the do-while loop the if body is executed if `eof` is true, which means the continue statement is redundant because the while loop condition contains `!eof`, so the do-while body doesn't get executed again after that. Change-Id: If0685eb482f29b88e9c8660886392483a3bd75ec Reviewed-by: Thiago Macieira --- src/corelib/io/qfsfileengine.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp index 0ff7da1ac4e..2c86e85dd5b 100644 --- a/src/corelib/io/qfsfileengine.cpp +++ b/src/corelib/io/qfsfileengine.cpp @@ -621,17 +621,15 @@ qint64 QFSFileEnginePrivate::readFdFh(char *data, qint64 len) // Buffered stdlib mode. size_t result; - bool retry = true; do { result = fread(data + readBytes, 1, size_t(len - readBytes), fh); eof = feof(fh); - if (retry && eof && result == 0) { + if (eof && result == 0) { // On OS X, this is needed, e.g., if a file was written to // through another stream since our last read. See test // tst_QFile::appendAndRead QT_FSEEK(fh, QT_FTELL(fh), SEEK_SET); // re-sync stream. - retry = false; - continue; + break; } readBytes += result; } while (!eof && (result == 0 ? errno == EINTR : readBytes < len));