Whitespace cleanup in corelib/io

Selective application of clang-format to follow our coding style where
it is significantly off.

Change-Id: I0ff4ed146fe53922691d5473d0c236f31d478a04
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Allan Sandfeld Jensen 2020-10-20 09:30:00 +02:00
parent 80a2878e20
commit b6cd3bca28
18 changed files with 224 additions and 224 deletions

View File

@ -45,7 +45,6 @@
QT_BEGIN_NAMESPACE
class QObject;
class QBufferPrivate;

View File

@ -267,11 +267,7 @@ private:
friend class QDirIterator;
// Q_DECLARE_PRIVATE equivalent for shared data pointers
QDirPrivate *d_func();
inline const QDirPrivate* d_func() const
{
return d_ptr.constData();
}
const QDirPrivate *d_func() const { return d_ptr.constData(); }
};
Q_DECLARE_SHARED(QDir)

View File

@ -44,9 +44,9 @@
QT_BEGIN_NAMESPACE
class QDirIteratorPrivate;
class Q_CORE_EXPORT QDirIterator {
class Q_CORE_EXPORT QDirIterator
{
public:
enum IteratorFlag {
NoIteratorFlags = 0x0,

View File

@ -61,8 +61,7 @@ QFileDevicePrivate::QFileDevicePrivate()
writeBufferChunkSize = QFILE_WRITEBUFFER_SIZE;
}
QFileDevicePrivate::~QFileDevicePrivate()
= default;
QFileDevicePrivate::~QFileDevicePrivate() = default;
QAbstractFileEngine *QFileDevicePrivate::engine() const
{

View File

@ -61,7 +61,8 @@
QT_BEGIN_NAMESPACE
struct ProcessOpenModeResult {
struct ProcessOpenModeResult
{
bool ok;
QIODevice::OpenMode openMode;
QString error;

View File

@ -842,7 +842,7 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size,
NULL);
// Since this is a special case, we check if the return value was NULL and if so
// we change it to INVALID_HANDLE_VALUE to follow the logic inside this function.
if(0 == handle)
if (!handle)
handle = INVALID_HANDLE_VALUE;
#endif

View File

@ -89,7 +89,8 @@ public:
qint64 devicePos = 0;
qint64 transactionPos = 0;
class QRingBufferRef {
class QRingBufferRef
{
QRingBuffer *m_buf;
inline QRingBufferRef() : m_buf(nullptr) { }
friend class QIODevicePrivate;

View File

@ -177,8 +177,11 @@ void QLockFile::unlock()
QThread::msleep(1);
}
if (attempts == maxAttempts) {
qWarning() << "Could not remove our own lock file" << d->fileName << ". Either other users of the lock file are reading it constantly for 500 ms, or we (no longer) have permissions to delete the file";
// This is bad because other users of this lock file will now have to wait for the stale-lock-timeout...
qWarning() << "Could not remove our own lock file" << d->fileName
<< ". Either other users of the lock file are reading it constantly for 500 ms, "
"or we (no longer) have permissions to delete the file";
// This is bad because other users of this lock file will now have to wait for the
// stale-lock-timeout...
}
d->lockError = QLockFile::NoError;
d->isLocked = false;

View File

@ -360,7 +360,6 @@ bool QNonContiguousByteDeviceIoDeviceImpl::advanceReadPointer(qint64 amount)
currentReadBufferAmount = 0;
}
return true;
}
@ -441,7 +440,6 @@ qint64 QByteDeviceWrappingIoDevice::size() const
return byteDevice->size();
}
qint64 QByteDeviceWrappingIoDevice::readData(char *data, qint64 maxSize)
{
qint64 len;

View File

@ -76,7 +76,6 @@ public:
protected:
QNonContiguousByteDevice();
Q_SIGNALS:
void readyRead();
void readProgress(qint64 current, qint64 total);
@ -111,6 +110,7 @@ public:
bool reset() override;
qint64 size() const override;
qint64 pos() const override;
protected:
QByteArray *byteArray;
qint64 currentPosition;
@ -127,12 +127,12 @@ public:
bool reset() override;
qint64 size() const override;
qint64 pos() const override;
protected:
QSharedPointer<QRingBuffer> ringBuffer;
qint64 currentPosition;
};
class QNonContiguousByteDeviceIoDeviceImpl : public QNonContiguousByteDevice
{
Q_OBJECT
@ -145,6 +145,7 @@ public:
bool reset() override;
qint64 size() const override;
qint64 pos() const override;
protected:
QIODevice *device;
QByteArray *currentReadBuffer;
@ -167,6 +168,7 @@ public:
bool atEnd() const override;
bool reset() override;
qint64 size() const override;
protected:
QBuffer *buffer;
QByteArray byteArray;
@ -183,6 +185,7 @@ public:
bool atEnd() const override;
bool reset() override;
qint64 size() const override;
protected:
qint64 readData(char *data, qint64 maxSize) override;
qint64 writeData(const char *data, qint64 maxSize) override;

View File

@ -107,13 +107,15 @@ public:
{
}
inline bool hasNext() {
inline bool hasNext()
{
while (m_pos < m_len && m_data[m_pos] == m_splitChar)
++m_pos;
return m_pos < m_len;
}
inline QStringView next() {
inline QStringView next()
{
int start = m_pos;
while (m_pos < m_len && m_data[m_pos] != m_splitChar)
++m_pos;
@ -126,18 +128,17 @@ public:
QChar m_splitChar = QLatin1Char('/');
};
// resource glue
class QResourceRoot
{
public:
enum Flags
{
enum Flags {
// must match rcc.h
Compressed = 0x01,
Directory = 0x02,
CompressedZstd = 0x04
};
private:
const uchar *tree, *names, *payloads;
int version;
@ -318,8 +319,7 @@ public:
Q_DECLARE_PUBLIC(QResource)
};
void
QResourcePrivate::clear()
void QResourcePrivate::clear()
{
absoluteFilePath.clear();
compressionAlgo = QResource::NoCompression;
@ -336,8 +336,7 @@ QResourcePrivate::clear()
related.clear();
}
bool
QResourcePrivate::load(const QString &file)
bool QResourcePrivate::load(const QString &file)
{
related.clear();
const auto locker = qt_scoped_lock(resourceMutex());
@ -359,7 +358,8 @@ QResourcePrivate::load(const QString &file)
}
lastModified = res->lastModified(node);
} else if (res->isContainer(node) != container) {
qWarning("QResourceInfo: Resource [%s] has both data and children!", file.toLatin1().constData());
qWarning("QResourceInfo: Resource [%s] has both data and children!",
file.toLatin1().constData());
}
res->ref.ref();
related.append(res);
@ -376,8 +376,7 @@ QResourcePrivate::load(const QString &file)
return !related.isEmpty();
}
void
QResourcePrivate::ensureInitialized() const
void QResourcePrivate::ensureInitialized() const
{
if (!related.isEmpty())
return;
@ -408,8 +407,7 @@ QResourcePrivate::ensureInitialized() const
}
}
void
QResourcePrivate::ensureChildren() const
void QResourcePrivate::ensureChildren() const
{
ensureInitialized();
if (!children.isEmpty() || !container || related.isEmpty())
@ -466,7 +464,6 @@ qint64 QResourcePrivate::uncompressedSize() const
Q_UNREACHABLE();
#endif
}
}
return -1;
}
@ -483,8 +480,8 @@ qsizetype QResourcePrivate::decompress(char *buffer, qsizetype bufferSize) const
case QResource::ZlibCompression: {
#ifndef QT_NO_COMPRESS
uLong len = uLong(bufferSize);
int res = ::uncompress(reinterpret_cast<Bytef *>(buffer), &len,
data + sizeof(quint32), uLong(size - sizeof(quint32)));
int res = ::uncompress(reinterpret_cast<Bytef *>(buffer), &len, data + sizeof(quint32),
uLong(size - sizeof(quint32)));
if (res != Z_OK) {
qWarning("QResource: error decompressing zlib content (%d)", res);
return -1;
@ -865,7 +862,8 @@ int QResourceRoot::findNode(const QString &_path, const QLocale &locale) const
if (hash(sub_node) == h) {
while (sub_node > child && hash(sub_node - 1) == h) // backup for collisions
--sub_node;
for(; sub_node < child+child_count && hash(sub_node) == h; ++sub_node) { //here we go...
for (; sub_node < child + child_count && hash(sub_node) == h;
++sub_node) { // here we go...
if (name(sub_node) == segment) {
found = true;
int offset = findOffset(sub_node);
@ -892,8 +890,10 @@ int QResourceRoot::findNode(const QString &_path, const QLocale &locale) const
qDebug() << "!!!!" << "FINISHED" << __LINE__ << sub_node;
#endif
return sub_node;
} else if((country == QLocale::AnyCountry && language == locale.language()) ||
(country == QLocale::AnyCountry && language == QLocale::C && node == -1)) {
} else if ((country == QLocale::AnyCountry
&& language == locale.language())
|| (country == QLocale::AnyCountry && language == QLocale::C
&& node == -1)) {
node = sub_node;
}
continue;
@ -1083,8 +1083,8 @@ public:
int offset = 0;
// magic number
if(b[offset+0] != 'q' || b[offset+1] != 'r' ||
b[offset+2] != 'e' || b[offset+3] != 's') {
if (b[offset + 0] != 'q' || b[offset + 1] != 'r' || b[offset + 2] != 'e'
|| b[offset + 3] != 's') {
return false;
}
offset += 4;
@ -1144,7 +1144,7 @@ public:
~QDynamicFileResourceRoot() {
#if defined(QT_USE_MMAP)
if (unmapPointer) {
munmap((char*)unmapPointer, unmapLength);
munmap(reinterpret_cast<char *>(unmapPointer), unmapLength);
unmapPointer = nullptr;
unmapLength = 0;
} else
@ -1199,7 +1199,7 @@ bool QDynamicFileResourceRoot::registerSelf(const QString &f)
if (fsize <= std::numeric_limits<qsizetype>::max()) {
data_len = file.size();
data = new uchar[data_len];
ok = (data_len == file.read((char*)data, data_len));
ok = (data_len == file.read(reinterpret_cast<char *>(data), data_len));
}
}
if (!ok) {
@ -1221,7 +1221,8 @@ bool QDynamicFileResourceRoot::registerSelf(const QString &f)
return false;
}
static QString qt_resource_fixResourceRoot(QString r) {
static QString qt_resource_fixResourceRoot(QString r)
{
if (!r.isEmpty()) {
if (r.startsWith(QLatin1Char(':')))
r = r.mid(1);
@ -1231,7 +1232,6 @@ static QString qt_resource_fixResourceRoot(QString r) {
return r;
}
/*!
\fn bool QResource::registerResource(const QString &rccFileName, const QString &mapRoot)
@ -1242,12 +1242,12 @@ static QString qt_resource_fixResourceRoot(QString r) {
\sa unregisterResource()
*/
bool
QResource::registerResource(const QString &rccFilename, const QString &resourceRoot)
bool QResource::registerResource(const QString &rccFilename, const QString &resourceRoot)
{
QString r = qt_resource_fixResourceRoot(resourceRoot);
if (!r.isEmpty() && r[0] != QLatin1Char('/')) {
qWarning("QDir::registerResource: Registering a resource [%ls] must be rooted in an absolute path (start with /) [%ls]",
qWarning("QDir::registerResource: Registering a resource [%ls] must be rooted in an "
"absolute path (start with /) [%ls]",
qUtf16Printable(rccFilename), qUtf16Printable(resourceRoot));
return false;
}
@ -1274,8 +1274,7 @@ QResource::registerResource(const QString &rccFilename, const QString &resourceR
\sa registerResource()
*/
bool
QResource::unregisterResource(const QString &rccFilename, const QString &resourceRoot)
bool QResource::unregisterResource(const QString &rccFilename, const QString &resourceRoot)
{
QString r = qt_resource_fixResourceRoot(resourceRoot);
@ -1298,7 +1297,6 @@ QResource::unregisterResource(const QString &rccFilename, const QString &resourc
return false;
}
/*!
\fn bool QResource::registerResource(const uchar *rccData, const QString &mapRoot)
\since 4.3
@ -1313,12 +1311,12 @@ QResource::unregisterResource(const QString &rccFilename, const QString &resourc
\sa unregisterResource()
*/
bool
QResource::registerResource(const uchar *rccData, const QString &resourceRoot)
bool QResource::registerResource(const uchar *rccData, const QString &resourceRoot)
{
QString r = qt_resource_fixResourceRoot(resourceRoot);
if (!r.isEmpty() && r[0] != QLatin1Char('/')) {
qWarning("QDir::registerResource: Registering a resource [%p] must be rooted in an absolute path (start with /) [%ls]",
qWarning("QDir::registerResource: Registering a resource [%p] must be rooted in an "
"absolute path (start with /) [%ls]",
rccData, qUtf16Printable(resourceRoot));
return false;
}
@ -1345,8 +1343,7 @@ QResource::registerResource(const uchar *rccData, const QString &resourceRoot)
\sa registerResource()
*/
bool
QResource::unregisterResource(const uchar *rccData, const QString &resourceRoot)
bool QResource::unregisterResource(const uchar *rccData, const QString &resourceRoot)
{
QString r = qt_resource_fixResourceRoot(resourceRoot);
@ -1548,7 +1545,8 @@ QAbstractFileEngine::FileFlags QResourceFileEngine::fileFlags(QAbstractFileEngin
return ret;
if (type & PermsMask)
ret |= QAbstractFileEngine::FileFlags(ReadOwnerPerm|ReadUserPerm|ReadGroupPerm|ReadOtherPerm);
ret |= QAbstractFileEngine::FileFlags(ReadOwnerPerm | ReadUserPerm | ReadGroupPerm
| ReadOtherPerm);
if (type & TypesMask) {
if (d->resource.isDir())
ret |= DirectoryType;
@ -1577,7 +1575,8 @@ QString QResourceFileEngine::fileName(FileName file) const
return d->resource.fileName();
return d->resource.fileName().mid(slash + 1);
} else if (file == PathName || file == AbsolutePathName) {
const QString path = (file == AbsolutePathName) ? d->resource.absoluteFilePath() : d->resource.fileName();
const QString path = (file == AbsolutePathName) ? d->resource.absoluteFilePath()
: d->resource.fileName();
const int slash = path.lastIndexOf(QLatin1Char('/'));
if (slash == -1)
return QLatin1String(":");
@ -1604,7 +1603,7 @@ bool QResourceFileEngine::isRelativePath() const
uint QResourceFileEngine::ownerId(FileOwner) const
{
static const uint nobodyID = (uint) -2;
static const uint nobodyID = static_cast<uint>(-2);
return nobodyID;
}
@ -1642,13 +1641,13 @@ bool QResourceFileEngine::extension(Extension extension, const ExtensionOption *
{
Q_D(QResourceFileEngine);
if (extension == MapExtension) {
const MapExtensionOption *options = (const MapExtensionOption*)(option);
MapExtensionReturn *returnValue = static_cast<MapExtensionReturn*>(output);
const auto *options = static_cast<const MapExtensionOption *>(option);
auto *returnValue = static_cast<MapExtensionReturn *>(output);
returnValue->address = d->map(options->offset, options->size, options->flags);
return (returnValue->address != nullptr);
}
if (extension == UnMapExtension) {
const UnMapExtensionOption *options = (const UnMapExtensionOption*)option;
const auto *options = static_cast<const UnMapExtensionOption *>(option);
return d->unmap(options->address);
}
return false;

View File

@ -106,6 +106,7 @@ private:
friend class QUrl;
friend Q_CORE_EXPORT size_t qHash(const QUrlQuery &key, size_t seed) noexcept;
QSharedDataPointer<QUrlQueryPrivate> d;
public:
typedef QSharedDataPointer<QUrlQueryPrivate> DataPtr;
inline DataPtr &data_ptr() { return d; }