From df8514a764a96b2dd571a2444573c2f0849abf4f Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 22 Sep 2023 13:47:33 -0700 Subject: [PATCH] QStorageInfo/Linux: simplify the code to deal with skipped entries In addition to what parseMountInfo() filtered, we also filter entries with zero total bytes (other than the root filesystem). This avoids creating yet another QStorageInfoPrivate that may not be used, but most importantly it avoids calling root() for that check, which would call parseMountInfo() again. Pick-to: 6.6 Change-Id: I9d43e5b91eb142d6945cfffd1787538dd3f285d0 Reviewed-by: Qt CI Bot Reviewed-by: Ahmad Samir Reviewed-by: Edward Welbourne --- src/corelib/io/qstorageinfo_linux.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/corelib/io/qstorageinfo_linux.cpp b/src/corelib/io/qstorageinfo_linux.cpp index 8b53629e253..1a27ac060ba 100644 --- a/src/corelib/io/qstorageinfo_linux.cpp +++ b/src/corelib/io/qstorageinfo_linux.cpp @@ -166,11 +166,10 @@ QList QStorageInfoPrivate::mountedVolumes() for (MountInfo &info : infos) { QStorageInfoPrivate d(std::move(info)); d.retrieveVolumeInfo(); - QStorageInfo storage(*new QStorageInfoPrivate(std::move(d))); - if (storage.bytesTotal() == 0 && storage != root()) + if (d.bytesTotal == 0 && d.rootPath != u'/') continue; - storage.d->name = retrieveLabel(storage.d->device); - volumes.push_back(storage); + d.name = retrieveLabel(d.device); + volumes.emplace_back(QStorageInfo(*new QStorageInfoPrivate(std::move(d)))); } return volumes; }