diff options
Diffstat (limited to 'src/corelib/io')
-rw-r--r-- | src/corelib/io/qfilesystemengine_unix.cpp | 20 | ||||
-rw-r--r-- | src/corelib/io/qloggingcategory.cpp | 4 | ||||
-rw-r--r-- | src/corelib/io/qstorageinfo_unix.cpp | 7 |
3 files changed, 13 insertions, 18 deletions
diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 0ffc4ca634..7975ac1d96 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -1113,7 +1113,6 @@ bool QFileSystemEngine::cloneFile(int srcfd, int dstfd, const QFileSystemMetaDat QT_STATBUF statBuffer; if (knownData.hasFlags(QFileSystemMetaData::PosixStatFlags) && knownData.isFile()) { - statBuffer.st_size = knownData.size(); statBuffer.st_mode = S_IFREG; } else if (knownData.hasFlags(QFileSystemMetaData::PosixStatFlags) && knownData.isDirectory()) { @@ -1126,29 +1125,23 @@ bool QFileSystemEngine::cloneFile(int srcfd, int dstfd, const QFileSystemMetaDat } #if defined(Q_OS_LINUX) - if (statBuffer.st_size == 0) { - // empty file? we're done. - return true; - } - // first, try FICLONE (only works on regular files and only on certain fs) if (::ioctl(dstfd, FICLONE, srcfd) == 0) return true; // Second, try sendfile (it can send to some special types too). // sendfile(2) is limited in the kernel to 2G - 4k - auto sendfileSize = [](QT_OFF_T size) { return size_t(qMin<qint64>(0x7ffff000, size)); }; + const size_t SendfileSize = 0x7ffff000; - ssize_t n = ::sendfile(dstfd, srcfd, NULL, sendfileSize(statBuffer.st_size)); + ssize_t n = ::sendfile(dstfd, srcfd, NULL, SendfileSize); if (n == -1) { // if we got an error here, give up and try at an upper layer return false; } - statBuffer.st_size -= n; - while (statBuffer.st_size) { - n = ::sendfile(dstfd, srcfd, NULL, sendfileSize(statBuffer.st_size)); - if (n == 0) { + while (n) { + n = ::sendfile(dstfd, srcfd, NULL, SendfileSize); + if (n == -1) { // uh oh, this is probably a real error (like ENOSPC), but we have // no way to notify QFile of partial success, so just erase any work // done (hopefully we won't get any errors, because there's nothing @@ -1158,9 +1151,6 @@ bool QFileSystemEngine::cloneFile(int srcfd, int dstfd, const QFileSystemMetaDat n = lseek(dstfd, 0, SEEK_SET); return false; } - if (n == 0) - return true; - statBuffer.st_size -= n; } return true; diff --git a/src/corelib/io/qloggingcategory.cpp b/src/corelib/io/qloggingcategory.cpp index a6c27d19c0..d8402c4eb6 100644 --- a/src/corelib/io/qloggingcategory.cpp +++ b/src/corelib/io/qloggingcategory.cpp @@ -221,6 +221,8 @@ static void setBoolLane(QBasicAtomicInt *atomic, bool enable, int shift) All message types for this category are enabled by default. If \a category is \c{0}, the category name is changed to \c "default". + + Note that \a category must be kept valid during the lifetime of this object. */ QLoggingCategory::QLoggingCategory(const char *category) : d(0), @@ -235,6 +237,8 @@ QLoggingCategory::QLoggingCategory(const char *category) If \a category is \c{0}, the category name is changed to \c "default". + Note that \a category must be kept valid during the lifetime of this object. + \since 5.4 */ QLoggingCategory::QLoggingCategory(const char *category, QtMsgType enableForLevel) diff --git a/src/corelib/io/qstorageinfo_unix.cpp b/src/corelib/io/qstorageinfo_unix.cpp index 7664b77d81..b7621b5d2f 100644 --- a/src/corelib/io/qstorageinfo_unix.cpp +++ b/src/corelib/io/qstorageinfo_unix.cpp @@ -342,13 +342,14 @@ inline bool QStorageIterator::isValid() const inline bool QStorageIterator::next() { QList<QByteArray> data; + // If file is virtual, file.readLine() may succeed even when file.atEnd(). do { const QByteArray line = file.readLine(); + if (line.isEmpty() && file.atEnd()) + return false; data = line.split(' '); - } while (data.count() < 3 && !file.atEnd()); + } while (data.count() < 4); - if (file.atEnd()) - return false; m_device = data.at(0); m_rootPath = data.at(1); m_fileSystemType = data.at(2); |