Commit b6cd3bca authored by Allan Sandfeld Jensen's avatar Allan Sandfeld Jensen

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: default avatarFriedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: default avatarTor Arne Vestbø <tor.arne.vestbo@qt.io>
parent 80a2878e
......@@ -45,7 +45,6 @@
QT_BEGIN_NAMESPACE
class QObject;
class QBufferPrivate;
......@@ -57,11 +56,11 @@ class Q_CORE_EXPORT QBuffer : public QIODevice
public:
#ifndef QT_NO_QOBJECT
explicit QBuffer(QObject *parent = nullptr);
QBuffer(QByteArray *buf, QObject *parent = nullptr);
explicit QBuffer(QObject *parent = nullptr);
QBuffer(QByteArray *buf, QObject *parent = nullptr);
#else
QBuffer();
explicit QBuffer(QByteArray *buf);
QBuffer();
explicit QBuffer(QByteArray *buf);
#endif
~QBuffer();
......
......@@ -213,7 +213,7 @@ public:
bool makeAbsolute();
bool operator==(const QDir &dir) const;
inline bool operator!=(const QDir &dir) const { return !operator==(dir); }
inline bool operator!=(const QDir &dir) const { return !operator==(dir); }
bool remove(const QString &fileName);
bool rename(const QString &oldName, const QString &newName);
......@@ -266,12 +266,8 @@ protected:
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();
}
QDirPrivate *d_func();
const QDirPrivate *d_func() const { return d_ptr.constData(); }
};
Q_DECLARE_SHARED(QDir)
......
......@@ -44,9 +44,9 @@
QT_BEGIN_NAMESPACE
class QDirIteratorPrivate;
class Q_CORE_EXPORT QDirIterator {
class Q_CORE_EXPORT QDirIterator
{
public:
enum IteratorFlag {
NoIteratorFlags = 0x0,
......
......@@ -61,10 +61,9 @@ QFileDevicePrivate::QFileDevicePrivate()
writeBufferChunkSize = QFILE_WRITEBUFFER_SIZE;
}
QFileDevicePrivate::~QFileDevicePrivate()
= default;
QFileDevicePrivate::~QFileDevicePrivate() = default;
QAbstractFileEngine * QFileDevicePrivate::engine() const
QAbstractFileEngine *QFileDevicePrivate::engine() const
{
if (!fileEngine)
fileEngine = qt_make_unique<QFSFileEngine>();
......
......@@ -61,7 +61,8 @@
QT_BEGIN_NAMESPACE
struct ProcessOpenModeResult {
struct ProcessOpenModeResult
{
bool ok;
QIODevice::OpenMode openMode;
QString error;
......
......@@ -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
......
......@@ -846,7 +846,7 @@ qint64 QIODevice::pos() const
*/
qint64 QIODevice::size() const
{
return d_func()->isSequential() ? bytesAvailable() : qint64(0);
return d_func()->isSequential() ? bytesAvailable() : qint64(0);
}
/*!
......@@ -1353,7 +1353,7 @@ qint64 QIODevice::readLine(char *data, qint64 maxSize)
// QRingBuffer::readLine() terminates the line with '\0'
readSoFar = d->buffer.readLine(data, maxSize + 1);
if (d->buffer.isEmpty())
readData(data,0);
readData(data, 0);
if (!sequential)
d->pos += readSoFar;
}
......
......@@ -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;
......
......@@ -167,21 +167,24 @@ QString QLockFilePrivate::processNameByPid(qint64 pid)
void QLockFile::unlock()
{
Q_D(QLockFile);
if (!d->isLocked)
if (!d->isLocked)
return;
CloseHandle(d->fileHandle);
int attempts = 0;
static const int maxAttempts = 500; // 500ms
while (!QFile::remove(d->fileName) && ++attempts < maxAttempts) {
// Someone is reading the lock file right now (on Windows this prevents deleting it).
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...
}
d->lockError = QLockFile::NoError;
d->isLocked = false;
CloseHandle(d->fileHandle);
int attempts = 0;
static const int maxAttempts = 500; // 500ms
while (!QFile::remove(d->fileName) && ++attempts < maxAttempts) {
// Someone is reading the lock file right now (on Windows this prevents deleting it).
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...
}
d->lockError = QLockFile::NoError;
d->isLocked = false;
}
QT_END_NAMESPACE
......@@ -74,7 +74,7 @@ public:
FullText = 0x1,
LeftFilter = 0x2,
RightFilter = 0x4,
MidFilter = LeftFilter | RightFilter
MidFilter = LeftFilter | RightFilter
};
Q_DECLARE_FLAGS(PatternFlags, PatternFlag)
......@@ -144,7 +144,7 @@ private:
// protected by mutex:
QList<QLoggingRule> ruleSets[NumRuleSets];
QHash<QLoggingCategory*,QtMsgType> categories;
QHash<QLoggingCategory *, QtMsgType> categories;
QLoggingCategory::CategoryFilter categoryFilter;
friend class ::tst_QLoggingRegistry;
......
......@@ -297,7 +297,7 @@ QNonContiguousByteDeviceIoDeviceImpl::~QNonContiguousByteDeviceIoDeviceImpl()
delete currentReadBuffer;
}
const char* QNonContiguousByteDeviceIoDeviceImpl::readPointer(qint64 maximumLength, qint64 &len)
const char *QNonContiguousByteDeviceIoDeviceImpl::readPointer(qint64 maximumLength, qint64 &len)
{
if (eof == true) {
len = -1;
......@@ -360,7 +360,6 @@ bool QNonContiguousByteDeviceIoDeviceImpl::advanceReadPointer(qint64 amount)
currentReadBufferAmount = 0;
}
return true;
}
......@@ -374,7 +373,7 @@ bool QNonContiguousByteDeviceIoDeviceImpl::reset()
bool reset = (initialPosition == 0) ? device->reset() : device->seek(initialPosition);
if (reset) {
eof = false; // assume eof is false, it will be true after a read has been attempted
totalAdvancements = 0; //reset the progress counter
totalAdvancements = 0; // reset the progress counter
if (currentReadBuffer) {
delete currentReadBuffer;
currentReadBuffer = nullptr;
......@@ -441,8 +440,7 @@ qint64 QByteDeviceWrappingIoDevice::size() const
return byteDevice->size();
}
qint64 QByteDeviceWrappingIoDevice::readData( char * data, qint64 maxSize)
qint64 QByteDeviceWrappingIoDevice::readData(char *data, qint64 maxSize)
{
qint64 len;
const char *readPointer = byteDevice->readPointer(maxSize, len);
......@@ -454,7 +452,7 @@ qint64 QByteDeviceWrappingIoDevice::readData( char * data, qint64 maxSize)
return len;
}
qint64 QByteDeviceWrappingIoDevice::writeData( const char* data, qint64 maxSize)
qint64 QByteDeviceWrappingIoDevice::writeData(const char *data, qint64 maxSize)
{
Q_UNUSED(data);
Q_UNUSED(maxSize);
......@@ -482,10 +480,10 @@ qint64 QByteDeviceWrappingIoDevice::writeData( const char* data, qint64 maxSize)
\internal
*/
QNonContiguousByteDevice* QNonContiguousByteDeviceFactory::create(QIODevice *device)
QNonContiguousByteDevice *QNonContiguousByteDeviceFactory::create(QIODevice *device)
{
// shortcut if it is a QBuffer
if (QBuffer* buffer = qobject_cast<QBuffer*>(device)) {
if (QBuffer *buffer = qobject_cast<QBuffer *>(device)) {
return new QNonContiguousByteDeviceBufferImpl(buffer);
}
......@@ -566,7 +564,7 @@ QSharedPointer<QNonContiguousByteDevice> QNonContiguousByteDeviceFactory::create
\internal
*/
QIODevice* QNonContiguousByteDeviceFactory::wrap(QNonContiguousByteDevice* byteDevice)
QIODevice *QNonContiguousByteDeviceFactory::wrap(QNonContiguousByteDevice *byteDevice)
{
// ### FIXME if it already has been based on QIoDevice, we could that one out again
// and save some calling
......
......@@ -64,7 +64,7 @@ class Q_CORE_EXPORT QNonContiguousByteDevice : public QObject
{
Q_OBJECT
public:
virtual const char* readPointer(qint64 maximumLength, qint64 &len) = 0;
virtual const char *readPointer(qint64 maximumLength, qint64 &len) = 0;
virtual bool advanceReadPointer(qint64 amount) = 0;
virtual bool atEnd() const = 0;
virtual qint64 pos() const { return -1; }
......@@ -76,7 +76,6 @@ public:
protected:
QNonContiguousByteDevice();
Q_SIGNALS:
void readyRead();
void readProgress(qint64 current, qint64 total);
......@@ -85,16 +84,16 @@ Q_SIGNALS:
class Q_CORE_EXPORT QNonContiguousByteDeviceFactory
{
public:
static QNonContiguousByteDevice* create(QIODevice *device);
static QNonContiguousByteDevice *create(QIODevice *device);
static QSharedPointer<QNonContiguousByteDevice> createShared(QIODevice *device);
static QNonContiguousByteDevice* create(QByteArray *byteArray);
static QNonContiguousByteDevice *create(QByteArray *byteArray);
static QSharedPointer<QNonContiguousByteDevice> createShared(QByteArray *byteArray);
static QNonContiguousByteDevice* create(QSharedPointer<QRingBuffer> ringBuffer);
static QNonContiguousByteDevice *create(QSharedPointer<QRingBuffer> ringBuffer);
static QSharedPointer<QNonContiguousByteDevice> createShared(QSharedPointer<QRingBuffer> ringBuffer);
static QIODevice* wrap(QNonContiguousByteDevice* byteDevice);
static QIODevice *wrap(QNonContiguousByteDevice *byteDevice);
};
// the actual implementations
......@@ -105,14 +104,15 @@ class QNonContiguousByteDeviceByteArrayImpl : public QNonContiguousByteDevice
public:
QNonContiguousByteDeviceByteArrayImpl(QByteArray *ba);
~QNonContiguousByteDeviceByteArrayImpl();
const char* readPointer(qint64 maximumLength, qint64 &len) override;
const char *readPointer(qint64 maximumLength, qint64 &len) override;
bool advanceReadPointer(qint64 amount) override;
bool atEnd() const override;
bool reset() override;
qint64 size() const override;
qint64 pos() const override;
protected:
QByteArray* byteArray;
QByteArray *byteArray;
qint64 currentPosition;
};
......@@ -121,33 +121,34 @@ class QNonContiguousByteDeviceRingBufferImpl : public QNonContiguousByteDevice
public:
QNonContiguousByteDeviceRingBufferImpl(QSharedPointer<QRingBuffer> rb);
~QNonContiguousByteDeviceRingBufferImpl();
const char* readPointer(qint64 maximumLength, qint64 &len) override;
const char *readPointer(qint64 maximumLength, qint64 &len) override;
bool advanceReadPointer(qint64 amount) override;
bool atEnd() const override;
bool reset() override;
qint64 size() const override;
qint64 pos() const override;
protected:
QSharedPointer<QRingBuffer> ringBuffer;
qint64 currentPosition;
};
class QNonContiguousByteDeviceIoDeviceImpl : public QNonContiguousByteDevice
{
Q_OBJECT
public:
QNonContiguousByteDeviceIoDeviceImpl(QIODevice *d);
~QNonContiguousByteDeviceIoDeviceImpl();
const char* readPointer(qint64 maximumLength, qint64 &len) override;
const char *readPointer(qint64 maximumLength, qint64 &len) override;
bool advanceReadPointer(qint64 amount) override;
bool atEnd() const override;
bool reset() override;
qint64 size() const override;
qint64 pos() const override;
protected:
QIODevice* device;
QByteArray* currentReadBuffer;
QIODevice *device;
QByteArray *currentReadBuffer;
qint64 currentReadBufferSize;
qint64 currentReadBufferAmount;
qint64 currentReadBufferPosition;
......@@ -162,32 +163,34 @@ class QNonContiguousByteDeviceBufferImpl : public QNonContiguousByteDevice
public:
QNonContiguousByteDeviceBufferImpl(QBuffer *b);
~QNonContiguousByteDeviceBufferImpl();
const char* readPointer(qint64 maximumLength, qint64 &len) override;
const char *readPointer(qint64 maximumLength, qint64 &len) override;
bool advanceReadPointer(qint64 amount) override;
bool atEnd() const override;
bool reset() override;
qint64 size() const override;
protected:
QBuffer* buffer;
QBuffer *buffer;
QByteArray byteArray;
QNonContiguousByteDeviceByteArrayImpl* arrayImpl;
QNonContiguousByteDeviceByteArrayImpl *arrayImpl;
};
// ... and the reverse thing
class QByteDeviceWrappingIoDevice : public QIODevice
{
public:
QByteDeviceWrappingIoDevice (QNonContiguousByteDevice *bd);
~QByteDeviceWrappingIoDevice ();
QByteDeviceWrappingIoDevice(QNonContiguousByteDevice *bd);
~QByteDeviceWrappingIoDevice();
bool isSequential() const override;
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;
QNonContiguousByteDevice *byteDevice;
QNonContiguousByteDevice *byteDevice;
};
QT_END_NAMESPACE
......
This diff is collapsed.
......@@ -61,7 +61,7 @@ public:
ZstdCompression
};
QResource(const QString &file=QString(), const QLocale &locale=QLocale());
QResource(const QString &file = QString(), const QLocale &locale = QLocale());
~QResource();
void setFileName(const QString &file);
......
......@@ -95,7 +95,7 @@ static QCFType<CFPropertyListRef> macValue(const QVariant &value);
static CFArrayRef macList(const QList<QVariant> &list)
{
int n = list.size();
QVarLengthArray<QCFType<CFPropertyListRef> > cfvalues(n);
QVarLengthArray<QCFType<CFPropertyListRef>> cfvalues(n);
for (int i = 0; i < n; ++i)
cfvalues[i] = macValue(list.at(i));
return CFArrayCreate(kCFAllocatorDefault, reinterpret_cast<const void **>(cfvalues.data()),
......
......@@ -94,7 +94,7 @@ class QSettingsKey : public QString
{
public:
inline QSettingsKey(const QString &key, Qt::CaseSensitivity cs, int position = -1)
: QString(key), theOriginalKey(key), theOriginalKeyPosition(position)
: QString(key), theOriginalKey(key), theOriginalKeyPosition(position)
{
if (cs == Qt::CaseInsensitive)
QString::operator=(toLower());
......
......@@ -456,12 +456,12 @@ QDebug operator<<(QDebug debug, const QStorageInfo &s)
debug << (d->ready ? " [ready]" : " [not ready]");
if (d->bytesTotal > 0) {
debug << ", bytesTotal=" << d->bytesTotal << ", bytesFree=" << d->bytesFree
<< ", bytesAvailable=" << d->bytesAvailable;
<< ", bytesAvailable=" << d->bytesAvailable;
}
} else {
debug << "invalid";
}
debug<< ')';
debug << ')';
return debug;
}
#endif // !QT_NO_DEBUG_STREAM
......
......@@ -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; }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment