summaryrefslogtreecommitdiffstats
path: root/src/corelib/io
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2023-09-22 13:47:33 -0700
committerThiago Macieira <thiago.macieira@intel.com>2023-10-16 08:41:21 -0700
commitdf8514a764a96b2dd571a2444573c2f0849abf4f (patch)
treeea085f07f08d125ccab216bb55e16d70e2d194a9 /src/corelib/io
parentc82ed8b2795cbf6d82dfe3857fec7c16688137a4 (diff)
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 <qt_ci_bot@qt-project.org> Reviewed-by: Ahmad Samir <a.samirh78@gmail.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/corelib/io')
-rw-r--r--src/corelib/io/qstorageinfo_linux.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/corelib/io/qstorageinfo_linux.cpp b/src/corelib/io/qstorageinfo_linux.cpp
index 8b53629e25..1a27ac060b 100644
--- a/src/corelib/io/qstorageinfo_linux.cpp
+++ b/src/corelib/io/qstorageinfo_linux.cpp
@@ -166,11 +166,10 @@ QList<QStorageInfo> 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;
}