Skip to content

Commit

Permalink
qstorageinfo_p.h: fix -Wunused-function
Browse files Browse the repository at this point in the history
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 543ae6e.

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 <thiago.macieira@intel.com>
(cherry picked from commit 5cd154d)
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Lena Biliaieva <lena.biliaieva@qt.io>
  • Loading branch information
marcmutz committed Sep 29, 2024
1 parent 848cc2b commit 7df3f20
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
3 changes: 2 additions & 1 deletion src/corelib/io/qstorageinfo_linux_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<dev_t> devno = deviceNumber(fields[DevNo]);
Expand Down
25 changes: 15 additions & 10 deletions src/corelib/io/qstorageinfo_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,18 @@ class QStorageInfoPrivate : public QSharedData
void retrieveVolumeInfo();
#endif

#ifdef Q_OS_UNIX
// Common helper functions
template <typename String>
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;
Expand All @@ -107,16 +119,8 @@ class QStorageInfoPrivate : public QSharedData
bool valid = false;
};

// Common helper functions
template <typename String>
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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 7df3f20

Please sign in to comment.