diff options
author | João Abecasis <joao@abecasis.name> | 2009-10-23 09:15:56 (GMT) |
---|---|---|
committer | João Abecasis <joao@abecasis.name> | 2009-10-23 13:05:33 (GMT) |
commit | 3be1b879c9fbe37b71cce3c95ec4a3753a25a641 (patch) | |
tree | 0a8c3fcda691a70068484d9c7d9174a846a78516 | |
parent | d0fa7d4b30fa34fe2a684c331213528c193da85f (diff) | |
download | Qt-3be1b879c9fbe37b71cce3c95ec4a3753a25a641.zip Qt-3be1b879c9fbe37b71cce3c95ec4a3753a25a641.tar.gz Qt-3be1b879c9fbe37b71cce3c95ec4a3753a25a641.tar.bz2 |
Check for non-zero return from fseek
While POSIX specifies a -1 return on error, on Windows only non-zero is
documented for error conditions. All platforms agree that zero is
returned on success so we check for that instead.
Reviewed-by: Markus Goetz
-rw-r--r-- | src/corelib/io/qfsfileengine.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp index c34f8ad..a7de896 100644 --- a/src/corelib/io/qfsfileengine.cpp +++ b/src/corelib/io/qfsfileengine.cpp @@ -317,9 +317,9 @@ bool QFSFileEnginePrivate::openFh(QIODevice::OpenMode openMode, FILE *fh) int ret; do { ret = QT_FSEEK(fh, 0, SEEK_END); - } while (ret == -1 && errno == EINTR); + } while (ret != 0 && errno == EINTR); - if (ret == -1) { + if (ret != 0) { q->setError(errno == EMFILE ? QFile::ResourceError : QFile::OpenError, qt_error_string(int(errno))); @@ -572,9 +572,9 @@ bool QFSFileEnginePrivate::seekFdFh(qint64 pos) int ret; do { ret = QT_FSEEK(fh, QT_OFF_T(pos), SEEK_SET); - } while (ret == -1 && errno == EINTR); + } while (ret != 0 && errno == EINTR); - if (ret == -1) { + if (ret != 0) { q->setError(QFile::ReadError, qt_error_string(int(errno))); return false; } |