From 7df3f20b9105d8a7360246a620978860cfaa5f7a Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 16 Sep 2024 15:03:25 +0200 Subject: [PATCH] qstorageinfo_p.h: fix -Wunused-function Make shouldIncludeFs() class- instead of file-static by moving it into QStorageInfoPrivate. Ditto isParentOf(). Put the functions under Q_OS_UNIX. Fixes Clang -Wunused-function, and removes a non-q/Q-prefixed name from the global namespace. Amends 543ae6e6a43519b9fca6758c4a8c78625fcb2c86. Manual conflict resolution for 6.8: - tracked a user of shouldIncludeFs() that needs a QStorageInfoPrivate:: prefix added from qstorageinfo_linux.cpp to qstorageinfo_linux_p.h Pick-to: 6.7 Task-number: QTBUG-77059 Task-number: QTBUG-126219 Change-Id: I4cc62ae044d74919d73d08f6ce3ad57f2e00b4c8 Reviewed-by: Thiago Macieira (cherry picked from commit 5cd154de63c517728d42ed322cb5f2965ef5f6ec) Reviewed-by: Ahmad Samir Reviewed-by: Lena Biliaieva --- src/corelib/io/qstorageinfo_linux_p.h | 3 ++- src/corelib/io/qstorageinfo_p.h | 25 +++++++++++++++---------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/corelib/io/qstorageinfo_linux_p.h b/src/corelib/io/qstorageinfo_linux_p.h index ae6c1a38592..f548f77446b 100644 --- a/src/corelib/io/qstorageinfo_linux_p.h +++ b/src/corelib/io/qstorageinfo_linux_p.h @@ -215,7 +215,8 @@ doParseMountInfo(const QByteArray &mountinfo, FilterMountInfo filter = FilterMou continue; info.fsType = fields[FsType].toByteArray(); - if (filter == FilterMountInfo::Filtered && !shouldIncludeFs(info.mountPoint, info.fsType)) + if (filter == FilterMountInfo::Filtered + && !QStorageInfoPrivate::shouldIncludeFs(info.mountPoint, info.fsType)) continue; std::optional devno = deviceNumber(fields[DevNo]); diff --git a/src/corelib/io/qstorageinfo_p.h b/src/corelib/io/qstorageinfo_p.h index 3b049cdfd47..d4c45954ffb 100644 --- a/src/corelib/io/qstorageinfo_p.h +++ b/src/corelib/io/qstorageinfo_p.h @@ -90,6 +90,18 @@ public: void retrieveVolumeInfo(); #endif +#ifdef Q_OS_UNIX + // Common helper functions + template + static bool isParentOf(const String &parent, const QString &dirName) + { + return dirName.startsWith(parent) && + (dirName.size() == parent.size() || dirName.at(parent.size()) == u'/' || + parent.size() == 1); + } + static inline bool shouldIncludeFs(const QString &mountDir, const QByteArray &fsType); +#endif + public: QString rootPath; QByteArray device; @@ -107,16 +119,8 @@ public: bool valid = false; }; -// Common helper functions -template -static bool isParentOf(const String &parent, const QString &dirName) -{ - return dirName.startsWith(parent) && - (dirName.size() == parent.size() || dirName.at(parent.size()) == u'/' || - parent.size() == 1); -} - -static inline bool shouldIncludeFs(const QString &mountDir, const QByteArray &fsType) +#ifdef Q_OS_UNIX +bool QStorageInfoPrivate::shouldIncludeFs(const QString &mountDir, const QByteArray &fsType) { #if defined(Q_OS_ANDROID) // "rootfs" is the filesystem type of "/" on Android @@ -158,6 +162,7 @@ static inline bool shouldIncludeFs(const QString &mountDir, const QByteArray &fs // size checking in QStorageInfo::mountedVolumes() return true; } +#endif // Q_OS_UNIX QT_END_NAMESPACE