summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/thread
diff options
context:
space:
mode:
authorSona Kurazyan <sona.kurazyan@qt.io>2020-12-14 14:45:43 +0100
committerSona Kurazyan <sona.kurazyan@qt.io>2020-12-17 14:33:56 +0100
commitd75c5026e919a9a031f900456ffef7752a03fa27 (patch)
tree08e57c4583f096e516e0da30c4a398cf00433b9d /tests/auto/corelib/thread
parent1ec4a7eddc9d521cb84fdf2fe19608f2d446bcb8 (diff)
Clean-up warnings in corelib/thread tests
Fixed the following warnings: - empty expression statement has no effect; remove unnecessary ';' to silence this warning - zero as null pointer constant - no previous extern declaration for non-static variable - use of old-style cast - integer conversion warnings Change-Id: Ieb31b127ce8e3b543aaf88a8e8fc463dcc8bc4e3 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'tests/auto/corelib/thread')
-rw-r--r--tests/auto/corelib/thread/qatomicpointer/tst_qatomicpointer.cpp8
-rw-r--r--tests/auto/corelib/thread/qfuture/tst_qfuture.cpp24
-rw-r--r--tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp8
-rw-r--r--tests/auto/corelib/thread/qmutex/tst_qmutex.cpp18
-rw-r--r--tests/auto/corelib/thread/qmutexlocker/tst_qmutexlocker.cpp6
-rw-r--r--tests/auto/corelib/thread/qpromise/tst_qpromise.cpp4
-rw-r--r--tests/auto/corelib/thread/qreadlocker/tst_qreadlocker.cpp6
-rw-r--r--tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp26
-rw-r--r--tests/auto/corelib/thread/qresultstore/tst_qresultstore.cpp2
-rw-r--r--tests/auto/corelib/thread/qsemaphore/tst_qsemaphore.cpp36
-rw-r--r--tests/auto/corelib/thread/qthread/tst_qthread.cpp40
-rw-r--r--tests/auto/corelib/thread/qthreadonce/tst_qthreadonce.cpp4
-rw-r--r--tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp26
-rw-r--r--tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp22
-rw-r--r--tests/auto/corelib/thread/qwaitcondition/tst_qwaitcondition.cpp8
-rw-r--r--tests/auto/corelib/thread/qwritelocker/tst_qwritelocker.cpp6
16 files changed, 122 insertions, 122 deletions
diff --git a/tests/auto/corelib/thread/qatomicpointer/tst_qatomicpointer.cpp b/tests/auto/corelib/thread/qatomicpointer/tst_qatomicpointer.cpp
index 4361609442..c2aff5a70a 100644
--- a/tests/auto/corelib/thread/qatomicpointer/tst_qatomicpointer.cpp
+++ b/tests/auto/corelib/thread/qatomicpointer/tst_qatomicpointer.cpp
@@ -73,7 +73,7 @@ void tst_QAtomicPointer::warningFreeHelper()
{
qFatal("This code is bogus, and shouldn't be run. We're looking for compiler warnings only.");
- QBasicAtomicPointer<WFHC> p = Q_BASIC_ATOMIC_INITIALIZER(0);
+ QBasicAtomicPointer<WFHC> p = Q_BASIC_ATOMIC_INITIALIZER(nullptr);
p.loadRelaxed()->bar();
@@ -645,8 +645,8 @@ void tst_QAtomicPointer::forwardDeclared()
// this is just a compilation test
QAtomicPointer<ForwardDeclared> ptr;
ContainsForwardDeclared cfd;
- Q_UNUSED(ptr);
- Q_UNUSED(cfd);
+ Q_UNUSED(ptr)
+ Q_UNUSED(cfd)
QVERIFY(true);
}
@@ -661,7 +661,7 @@ template <typename T> static void operators_helper()
{
// Test that QBasicAtomicPointer also has operator= and cast operators
// We've been using them for QAtomicPointer<T> elsewhere
- QBasicAtomicPointer<T> atomic = Q_BASIC_ATOMIC_INITIALIZER(0);
+ QBasicAtomicPointer<T> atomic = Q_BASIC_ATOMIC_INITIALIZER(nullptr);
atomic = one;
QCOMPARE(Ptr(atomic), one);
}
diff --git a/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp b/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp
index 3616500af8..df8948f767 100644
--- a/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp
+++ b/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp
@@ -1182,13 +1182,13 @@ void tst_QFuture::iterators()
QVERIFY(c2 != c1);
int x1 = *i1;
- Q_UNUSED(x1);
+ Q_UNUSED(x1)
int x2 = *i2;
- Q_UNUSED(x2);
+ Q_UNUSED(x2)
int y1 = *c1;
- Q_UNUSED(y1);
+ Q_UNUSED(y1)
int y2 = *c2;
- Q_UNUSED(y2);
+ Q_UNUSED(y2)
}
{
@@ -1240,10 +1240,10 @@ void tst_QFuture::iterators()
QCOMPARE(x1, y1);
QCOMPARE(x2, y2);
- int i1Size = i1->size();
- int i2Size = i2->size();
- int c1Size = c1->size();
- int c2Size = c2->size();
+ auto i1Size = i1->size();
+ auto i2Size = i2->size();
+ auto c1Size = c1->size();
+ auto c2Size = c2->size();
QCOMPARE(i1Size, c1Size);
QCOMPARE(i2Size, c2Size);
@@ -1688,7 +1688,7 @@ void tst_QFuture::exceptions()
bool caught = false;
try {
foreach (int e, f.results()) {
- Q_UNUSED(e);
+ Q_UNUSED(e)
QFAIL("did not get exception");
}
} catch (QException &) {
@@ -1755,7 +1755,7 @@ void tst_QFuture::nestedExceptions()
{
try {
MyClass m;
- Q_UNUSED(m);
+ Q_UNUSED(m)
throw 0;
} catch (int) {}
@@ -1783,7 +1783,7 @@ void tst_QFuture::nonGlobalThreadPool()
void run() override
{
const int ms = 100 + (QRandomGenerator::global()->bounded(100) - 100/2);
- QThread::msleep(ms);
+ QThread::msleep(ulong(ms));
reportResult(Answer);
reportFinished();
}
@@ -2913,7 +2913,7 @@ void tst_QFuture::testSingleResult(const std::vector<int> &v)
template<class T>
void tst_QFuture::testSingleResult(const T &unknown)
{
- Q_UNUSED(unknown);
+ Q_UNUSED(unknown)
}
diff --git a/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp b/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp
index e83ea07dd4..e5952e7c8d 100644
--- a/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp
+++ b/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp
@@ -114,9 +114,9 @@ void mapSleeper(int &)
QTest::qSleep(100);
}
-QSet<int> progressValues;
-QSet<QString> progressTexts;
-QMutex mutex;
+static QSet<int> progressValues;
+static QSet<QString> progressTexts;
+static QMutex mutex;
class ProgressObject : public QObject
{
Q_OBJECT
@@ -191,7 +191,7 @@ class CancelObject : public QObject
Q_OBJECT
public:
bool wasCanceled;
- CancelObject() : wasCanceled(false) {};
+ CancelObject() : wasCanceled(false) {}
public slots:
void cancel();
};
diff --git a/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp b/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp
index a2e71c0a24..88ecee7999 100644
--- a/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp
+++ b/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp
@@ -46,7 +46,7 @@ public:
Milliseconds,
Seconds,
};
- Q_ENUM(TimeUnit);
+ Q_ENUM(TimeUnit)
private slots:
void convertToMilliseconds_data();
@@ -68,11 +68,11 @@ private slots:
static const int iterations = 100;
-QAtomicInt lockCount(0);
-QMutex normalMutex;
-QRecursiveMutex recursiveMutex;
-QSemaphore testsTurn;
-QSemaphore threadsTurn;
+static QAtomicInt lockCount(0);
+static QMutex normalMutex;
+static QRecursiveMutex recursiveMutex;
+static QSemaphore testsTurn;
+static QSemaphore threadsTurn;
/*
Depending on the OS, tryWaits may return early than expected because of the
@@ -1288,14 +1288,14 @@ public:
quint64 i = 0;
while (t.elapsed() < one_minute) {
i++;
- uint nb = (i * 9 + lockCount.loadRelaxed() * 13) % threadCount;
+ uint nb = (i * 9 + uint(lockCount.loadRelaxed()) * 13) % threadCount;
QMutexLocker locker(&mutex[nb]);
if (sentinel[nb].loadRelaxed()) errorCount.ref();
if (sentinel[nb].fetchAndAddRelaxed(5)) errorCount.ref();
if (!sentinel[nb].testAndSetRelaxed(5, 0)) errorCount.ref();
if (sentinel[nb].loadRelaxed()) errorCount.ref();
lockCount.ref();
- nb = (nb * 17 + i * 5 + lockCount.loadRelaxed() * 3) % threadCount;
+ nb = (nb * 17 + i * 5 + uint(lockCount.loadRelaxed()) * 3) % threadCount;
if (mutex[nb].tryLock()) {
if (sentinel[nb].loadRelaxed()) errorCount.ref();
if (sentinel[nb].fetchAndAddRelaxed(16)) errorCount.ref();
@@ -1304,7 +1304,7 @@ public:
lockCount.ref();
mutex[nb].unlock();
}
- nb = (nb * 15 + i * 47 + lockCount.loadRelaxed() * 31) % threadCount;
+ nb = (nb * 15 + i * 47 + uint(lockCount.loadRelaxed()) * 31) % threadCount;
if (mutex[nb].tryLock(2)) {
if (sentinel[nb].loadRelaxed()) errorCount.ref();
if (sentinel[nb].fetchAndAddRelaxed(53)) errorCount.ref();
diff --git a/tests/auto/corelib/thread/qmutexlocker/tst_qmutexlocker.cpp b/tests/auto/corelib/thread/qmutexlocker/tst_qmutexlocker.cpp
index 46cdd8073e..30268890ed 100644
--- a/tests/auto/corelib/thread/qmutexlocker/tst_qmutexlocker.cpp
+++ b/tests/auto/corelib/thread/qmutexlocker/tst_qmutexlocker.cpp
@@ -110,7 +110,7 @@ void tst_QMutexLocker::scopeTest()
QVERIFY(thread->wait());
delete thread;
- thread = 0;
+ thread = nullptr;
}
@@ -157,7 +157,7 @@ void tst_QMutexLocker::unlockAndRelockTest()
QVERIFY(thread->wait());
delete thread;
- thread = 0;
+ thread = nullptr;
}
void tst_QMutexLocker::lockerStateTest()
@@ -197,7 +197,7 @@ void tst_QMutexLocker::lockerStateTest()
QVERIFY(thread->wait());
delete thread;
- thread = 0;
+ thread = nullptr;
}
QTEST_MAIN(tst_QMutexLocker)
diff --git a/tests/auto/corelib/thread/qpromise/tst_qpromise.cpp b/tests/auto/corelib/thread/qpromise/tst_qpromise.cpp
index 82a359451d..74a3059699 100644
--- a/tests/auto/corelib/thread/qpromise/tst_qpromise.cpp
+++ b/tests/auto/corelib/thread/qpromise/tst_qpromise.cpp
@@ -77,7 +77,7 @@ private slots:
struct TrivialType { int field = 0; };
struct CopyOnlyType {
- Q_DISABLE_MOVE(CopyOnlyType);
+ Q_DISABLE_MOVE(CopyOnlyType)
CopyOnlyType() = default;
CopyOnlyType(const CopyOnlyType &) = default;
CopyOnlyType& operator=(const CopyOnlyType &) = default;
@@ -86,7 +86,7 @@ struct CopyOnlyType {
int field = 0;
};
struct MoveOnlyType {
- Q_DISABLE_COPY(MoveOnlyType);
+ Q_DISABLE_COPY(MoveOnlyType)
MoveOnlyType() = default;
MoveOnlyType(MoveOnlyType &&) = default;
MoveOnlyType& operator=(MoveOnlyType &&) = default;
diff --git a/tests/auto/corelib/thread/qreadlocker/tst_qreadlocker.cpp b/tests/auto/corelib/thread/qreadlocker/tst_qreadlocker.cpp
index 241f064a21..8f0b182d05 100644
--- a/tests/auto/corelib/thread/qreadlocker/tst_qreadlocker.cpp
+++ b/tests/auto/corelib/thread/qreadlocker/tst_qreadlocker.cpp
@@ -109,7 +109,7 @@ void tst_QReadLocker::scopeTest()
QVERIFY(thread->wait());
delete thread;
- thread = 0;
+ thread = nullptr;
}
@@ -156,7 +156,7 @@ void tst_QReadLocker::unlockAndRelockTest()
QVERIFY(thread->wait());
delete thread;
- thread = 0;
+ thread = nullptr;
}
void tst_QReadLocker::lockerStateTest()
@@ -196,7 +196,7 @@ void tst_QReadLocker::lockerStateTest()
QVERIFY(thread->wait());
delete thread;
- thread = 0;
+ thread = nullptr;
}
QTEST_MAIN(tst_QReadLocker)
diff --git a/tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp b/tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp
index 76e50eee1b..12bc4ba6af 100644
--- a/tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp
+++ b/tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp
@@ -184,10 +184,10 @@ void tst_QReadWriteLock::readWriteLockUnlockLoop()
}
-QAtomicInt lockCount(0);
-QReadWriteLock readWriteLock;
-QSemaphore testsTurn;
-QSemaphore threadsTurn;
+static QAtomicInt lockCount(0);
+static QReadWriteLock readWriteLock;
+static QSemaphore testsTurn;
+static QSemaphore threadsTurn;
void tst_QReadWriteLock::tryReadLock()
@@ -403,8 +403,8 @@ void tst_QReadWriteLock::tryWriteLock()
}
}
-bool threadDone;
-QAtomicInt release;
+static bool threadDone;
+static QAtomicInt release;
/*
write-lock
@@ -511,9 +511,9 @@ public:
while (t.elapsed()<runTime) {
testRwlock.lockForRead();
if(print) printf("reading\n");
- if (holdTime) msleep(holdTime);
+ if (holdTime) msleep(ulong(holdTime));
testRwlock.unlock();
- if (waitTime) msleep(waitTime);
+ if (waitTime) msleep(ulong(waitTime));
}
}
};
@@ -547,14 +547,14 @@ public:
while (t.elapsed() < runTime) {
testRwlock.lockForWrite();
if (print) printf(".");
- if (holdTime) msleep(holdTime);
+ if (holdTime) msleep(ulong(holdTime));
testRwlock.unlock();
- if (waitTime) msleep(waitTime);
+ if (waitTime) msleep(ulong(waitTime));
}
}
};
-volatile int count=0;
+static volatile int count = 0;
/*
for(runTime msecs)
@@ -594,7 +594,7 @@ public:
}
count=0;
testRwlock.unlock();
- msleep(waitTime);
+ msleep(ulong(waitTime));
}
}
};
@@ -626,7 +626,7 @@ public:
if(count)
qFatal("Non-zero count at Read! (%d)",count );
testRwlock.unlock();
- msleep(waitTime);
+ msleep(ulong(waitTime));
}
}
};
diff --git a/tests/auto/corelib/thread/qresultstore/tst_qresultstore.cpp b/tests/auto/corelib/thread/qresultstore/tst_qresultstore.cpp
index 6e0bbda2c2..dff599180c 100644
--- a/tests/auto/corelib/thread/qresultstore/tst_qresultstore.cpp
+++ b/tests/auto/corelib/thread/qresultstore/tst_qresultstore.cpp
@@ -535,7 +535,7 @@ void tst_QtConcurrentResultStore::pendingResultsDoNotLeak_data()
void tst_QtConcurrentResultStore::pendingResultsDoNotLeak()
{
QFETCH(bool, filterMode);
- CountedObject::LeakChecker leakChecker; Q_UNUSED(leakChecker);
+ CountedObject::LeakChecker leakChecker; Q_UNUSED(leakChecker)
ResultStoreCountedObject store;
store.setFilterMode(filterMode);
diff --git a/tests/auto/corelib/thread/qsemaphore/tst_qsemaphore.cpp b/tests/auto/corelib/thread/qsemaphore/tst_qsemaphore.cpp
index f556e402e3..bce0088463 100644
--- a/tests/auto/corelib/thread/qsemaphore/tst_qsemaphore.cpp
+++ b/tests/auto/corelib/thread/qsemaphore/tst_qsemaphore.cpp
@@ -106,7 +106,7 @@ void tst_QSemaphore::acquire()
QVERIFY(t2.wait(4000));
delete semaphore;
- semaphore = 0;
+ semaphore = nullptr;
}
// old incrementN() test
@@ -126,7 +126,7 @@ void tst_QSemaphore::acquire()
QVERIFY(t2.wait(4000));
delete semaphore;
- semaphore = 0;
+ semaphore = nullptr;
}
QSemaphore semaphore;
@@ -177,7 +177,7 @@ void tst_QSemaphore::multiRelease()
// wait for all threads to reach the sem.acquire() and then
// release them all
QTest::qSleep(1);
- sem.release(threads.size());
+ sem.release(int(threads.size()));
for (Thread *&t : threads)
t->wait();
@@ -323,69 +323,69 @@ void tst_QSemaphore::tryAcquireWithTimeout()
QCOMPARE(semaphore.available(), 1);
time.start();
QVERIFY(!semaphore.tryAcquire(2, timeout));
- FUZZYCOMPARE(time.elapsed(), timeout);
+ FUZZYCOMPARE(int(time.elapsed()), timeout);
QCOMPARE(semaphore.available(), 1);
semaphore.release();
QCOMPARE(semaphore.available(), 2);
time.start();
QVERIFY(!semaphore.tryAcquire(3, timeout));
- FUZZYCOMPARE(time.elapsed(), timeout);
+ FUZZYCOMPARE(int(time.elapsed()), timeout);
QCOMPARE(semaphore.available(), 2);
semaphore.release(10);
QCOMPARE(semaphore.available(), 12);
time.start();
QVERIFY(!semaphore.tryAcquire(100, timeout));
- FUZZYCOMPARE(time.elapsed(), timeout);
+ FUZZYCOMPARE(int(time.elapsed()), timeout);
QCOMPARE(semaphore.available(), 12);
semaphore.release(10);
QCOMPARE(semaphore.available(), 22);
time.start();
QVERIFY(!semaphore.tryAcquire(100, timeout));
- FUZZYCOMPARE(time.elapsed(), timeout);
+ FUZZYCOMPARE(int(time.elapsed()), timeout);
QCOMPARE(semaphore.available(), 22);
time.start();
QVERIFY(semaphore.tryAcquire(1, timeout));
- FUZZYCOMPARE(time.elapsed(), 0);
+ FUZZYCOMPARE(int(time.elapsed()), 0);
QCOMPARE(semaphore.available(), 21);
time.start();
QVERIFY(semaphore.tryAcquire(1, timeout));
- FUZZYCOMPARE(time.elapsed(), 0);
+ FUZZYCOMPARE(int(time.elapsed()), 0);
QCOMPARE(semaphore.available(), 20);
time.start();
QVERIFY(semaphore.tryAcquire(10, timeout));
- FUZZYCOMPARE(time.elapsed(), 0);
+ FUZZYCOMPARE(int(time.elapsed()), 0);
QCOMPARE(semaphore.available(), 10);
time.start();
QVERIFY(semaphore.tryAcquire(10, timeout));
- FUZZYCOMPARE(time.elapsed(), 0);
+ FUZZYCOMPARE(int(time.elapsed()), 0);
QCOMPARE(semaphore.available(), 0);
// should not be able to acquire more
time.start();
QVERIFY(!semaphore.tryAcquire(1, timeout));
- FUZZYCOMPARE(time.elapsed(), timeout);
+ FUZZYCOMPARE(int(time.elapsed()), timeout);
QCOMPARE(semaphore.available(), 0);
time.start();
QVERIFY(!semaphore.tryAcquire(1, timeout));
- FUZZYCOMPARE(time.elapsed(), timeout);
+ FUZZYCOMPARE(int(time.elapsed()), timeout);
QCOMPARE(semaphore.available(), 0);
time.start();
QVERIFY(!semaphore.tryAcquire(10, timeout));
- FUZZYCOMPARE(time.elapsed(), timeout);
+ FUZZYCOMPARE(int(time.elapsed()), timeout);
QCOMPARE(semaphore.available(), 0);
time.start();
QVERIFY(!semaphore.tryAcquire(10, timeout));
- FUZZYCOMPARE(time.elapsed(), timeout);
+ FUZZYCOMPARE(int(time.elapsed()), timeout);
QCOMPARE(semaphore.available(), 0);
#undef FUZZYCOMPARE
@@ -481,7 +481,7 @@ const char alphabet[] = "ACGTH";
const int AlphabetSize = sizeof(alphabet) - 1;
const int BufferSize = 4096; // GCD of BufferSize and alphabet size must be 1
-char buffer[BufferSize];
+static char buffer[BufferSize];
const int ProducerChunkSize = 3;
const int ConsumerChunkSize = 7;
@@ -491,8 +491,8 @@ const int Multiplier = 10;
// ProducerChunkSize, ConsumerChunkSize, and BufferSize
const int DataSize = ProducerChunkSize * ConsumerChunkSize * BufferSize * Multiplier;
-QSemaphore freeSpace(BufferSize);
-QSemaphore usedSpace;
+static QSemaphore freeSpace(BufferSize);
+static QSemaphore usedSpace;
class Producer : public QThread
{
diff --git a/tests/auto/corelib/thread/qthread/tst_qthread.cpp b/tests/auto/corelib/thread/qthread/tst_qthread.cpp
index 1e8380fbba..3f5b255be4 100644
--- a/tests/auto/corelib/thread/qthread/tst_qthread.cpp
+++ b/tests/auto/corelib/thread/qthread/tst_qthread.cpp
@@ -241,9 +241,9 @@ public:
enum SleepType { Second, Millisecond, Microsecond };
SleepType sleepType;
- int interval;
+ ulong interval;
- int elapsed; // result, in *MILLISECONDS*
+ qint64 elapsed; // result, in *MILLISECONDS*
void run() override
{
@@ -272,25 +272,25 @@ public:
void tst_QThread::currentThreadId()
{
Current_Thread thread;
- thread.id = 0;
- thread.thread = 0;
+ thread.id = nullptr;
+ thread.thread = nullptr;
thread.start();
QVERIFY(thread.wait(five_minutes));
- QVERIFY(thread.id != 0);
+ QVERIFY(thread.id != nullptr);
QVERIFY(thread.id != QThread::currentThreadId());
}
void tst_QThread::currentThread()
{
- QVERIFY(QThread::currentThread() != 0);
+ QVERIFY(QThread::currentThread() != nullptr);
QCOMPARE(QThread::currentThread(), thread());
Current_Thread thread;
- thread.id = 0;
- thread.thread = 0;
+ thread.id = nullptr;
+ thread.thread = nullptr;
thread.start();
QVERIFY(thread.wait(five_minutes));
- QCOMPARE(thread.thread, (QThread *)&thread);
+ QCOMPARE(thread.thread, static_cast<QThread *>(&thread));
}
void tst_QThread::idealThreadCount()
@@ -646,7 +646,7 @@ void noop(void*) { }
class NativeThreadWrapper
{
public:
- NativeThreadWrapper() : qthread(0), waitForStop(false) {}
+ NativeThreadWrapper() : qthread(nullptr), waitForStop(false) {}
void start(FunctionPointer functionPointer = noop, void *data = nullptr);
void startAndWait(FunctionPointer functionPointer = noop, void *data = nullptr);
void join();
@@ -672,8 +672,8 @@ void NativeThreadWrapper::start(FunctionPointer functionPointer, void *data)
this->functionPointer = functionPointer;
this->data = data;
#if defined Q_OS_UNIX
- const int state = pthread_create(&nativeThreadHandle, 0, NativeThreadWrapper::runUnix, this);
- Q_UNUSED(state);
+ const int state = pthread_create(&nativeThreadHandle, nullptr, NativeThreadWrapper::runUnix, this);
+ Q_UNUSED(state)
#elif defined Q_OS_WIN
unsigned thrdid = 0;
nativeThreadHandle = (Qt::HANDLE) _beginthreadex(NULL, 0, NativeThreadWrapper::runWin, this, 0, &thrdid);
@@ -690,7 +690,7 @@ void NativeThreadWrapper::startAndWait(FunctionPointer functionPointer, void *da
void NativeThreadWrapper::join()
{
#if defined Q_OS_UNIX
- pthread_join(nativeThreadHandle, 0);
+ pthread_join(nativeThreadHandle, nullptr);
#elif defined Q_OS_WIN
WaitForSingleObjectEx(nativeThreadHandle, INFINITE, FALSE);
CloseHandle(nativeThreadHandle);
@@ -720,7 +720,7 @@ void *NativeThreadWrapper::runUnix(void *that)
nativeThreadWrapper->stopCondition.wait(lock.mutex());
}
- return 0;
+ return nullptr;
}
unsigned WIN_FIX_STDCALL NativeThreadWrapper::runWin(void *data)
@@ -736,12 +736,12 @@ void NativeThreadWrapper::stop()
stopCondition.wakeOne();
}
-bool threadAdoptedOk = false;
-QThread *mainThread;
+static bool threadAdoptedOk = false;
+static QThread *mainThread;
void testNativeThreadAdoption(void *)
{
- threadAdoptedOk = (QThread::currentThreadId() != 0
- && QThread::currentThread() != 0
+ threadAdoptedOk = (QThread::currentThreadId() != nullptr
+ && QThread::currentThread() != nullptr
&& QThread::currentThread() != mainThread);
}
void tst_QThread::nativeThreadAdoption()
@@ -769,7 +769,7 @@ void adoptedThreadAffinityFunction(void *arg)
void tst_QThread::adoptedThreadAffinity()
{
- QThread *affinity[2] = { 0, 0 };
+ QThread *affinity[2] = { nullptr, nullptr };
NativeThreadWrapper thread;
thread.startAndWait(adoptedThreadAffinityFunction, affinity);
@@ -1142,7 +1142,7 @@ void tst_QThread::startFinishRace()
void run() override
{
i--;
- if (!i) disconnect(this, SIGNAL(finished()), 0, 0);
+ if (!i) disconnect(this, SIGNAL(finished()), nullptr, nullptr);
}
int i;
};
diff --git a/tests/auto/corelib/thread/qthreadonce/tst_qthreadonce.cpp b/tests/auto/corelib/thread/qthreadonce/tst_qthreadonce.cpp
index 6859a55725..76974fc5fb 100644
--- a/tests/auto/corelib/thread/qthreadonce/tst_qthreadonce.cpp
+++ b/tests/auto/corelib/thread/qthreadonce/tst_qthreadonce.cpp
@@ -112,7 +112,7 @@ void tst_QThreadOnce::sameThread()
QCOMPARE(controlVariable, 1);
static QSingleton<SingletonObject> s;
- QTEST((int)s->val.loadRelaxed(), "expectedValue");
+ QTEST(int(s->val.loadRelaxed()), "expectedValue");
s->val.ref();
QCOMPARE(SingletonObject::runCount, 1);
@@ -145,7 +145,7 @@ void tst_QThreadOnce::multipleThreads()
delete parent;
QCOMPARE(controlVariable, 1);
- QCOMPARE((int)IncrementThread::runCount.loadRelaxed(), NumberOfThreads);
+ QCOMPARE(int(IncrementThread::runCount.loadRelaxed()), NumberOfThreads);
QCOMPARE(SingletonObject::runCount, 1);
}
diff --git a/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp b/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp
index e6db963c7b..fb563609e2 100644
--- a/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp
+++ b/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp
@@ -119,7 +119,7 @@ tst_QThreadPool::~tst_QThreadPool()
tst_QThreadPool::functionTestMutex = nullptr;
}
-int testFunctionCount;
+static int testFunctionCount;
void sleepTestFunction()
{
@@ -225,7 +225,7 @@ void tst_QThreadPool::waitcomplete()
QCOMPARE(testFunctionCount, runs);
}
-QAtomicInt ran; // bool
+static QAtomicInt ran; // bool
class TestTask : public QRunnable
{
public:
@@ -253,7 +253,7 @@ void tst_QThreadPool::singleton()
QTRY_VERIFY(ran.loadRelaxed());
}
-QAtomicInt *value = 0;
+static QAtomicInt *value = nullptr;
class IntAccessor : public QRunnable
{
public:
@@ -278,11 +278,11 @@ void tst_QThreadPool::destruction()
threadManager->start(new IntAccessor());
delete threadManager;
delete value;
- value = 0;
+ value = nullptr;
}
-QSemaphore threadRecyclingSemaphore;
-QThread *recycledThread = nullptr;
+static QSemaphore threadRecyclingSemaphore;
+static QThread *recycledThread = nullptr;
class ThreadRecorderTask : public QRunnable
{
@@ -328,7 +328,7 @@ public:
QSemaphore semaphore;
ExpiryTimeoutTask()
- : thread(0), runCount(0)
+ : thread(nullptr), runCount(0)
{
setAutoDelete(false);
}
@@ -720,7 +720,7 @@ void tst_QThreadPool::reserveAndStart() // QTBUG-21051
threadpool->setMaxThreadCount(savedLimit);
}
-QAtomicInt count;
+static QAtomicInt count;
class CountingRunnable : public QRunnable
{
public:
@@ -772,9 +772,9 @@ void tst_QThreadPool::tryStart()
QCOMPARE(count.loadRelaxed(), threadPool.maxThreadCount());
}
-QMutex mutex;
-QAtomicInt activeThreads;
-QAtomicInt peakActiveThreads;
+static QMutex mutex;
+static QAtomicInt activeThreads;
+static QAtomicInt peakActiveThreads;
void tst_QThreadPool::tryStartPeakThreadCount()
{
class CounterTask : public QRunnable
@@ -868,7 +868,7 @@ void tst_QThreadPool::priorityStart()
Runner(QAtomicPointer<QRunnable> &ptr) : ptr(ptr) {}
void run() override
{
- ptr.testAndSetRelaxed(0, this);
+ ptr.testAndSetRelaxed(nullptr, this);
}
};
@@ -1017,7 +1017,7 @@ void tst_QThreadPool::tryTake()
explicit BlockingRunnable(QSemaphore &s, QSemaphore &started, QAtomicInt &c, QAtomicInt &r)
: sem(s), startedThreads(started), dtorCounter(c), runCounter(r) {}
- ~BlockingRunnable()
+ ~BlockingRunnable() override
{
dtorCounter.fetchAndAddRelaxed(1);
}
diff --git a/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp b/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp
index ab1dd677e9..dfb4953c9d 100644
--- a/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp
+++ b/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp
@@ -76,7 +76,7 @@ void tst_QThreadStorage::hasLocalData()
QVERIFY(!pointers.hasLocalData());
pointers.setLocalData(new Pointer);
QVERIFY(pointers.hasLocalData());
- pointers.setLocalData(0);
+ pointers.setLocalData(nullptr);
QVERIFY(!pointers.hasLocalData());
}
@@ -88,8 +88,8 @@ void tst_QThreadStorage::localData()
pointers.setLocalData(p);
QVERIFY(pointers.hasLocalData());
QCOMPARE(pointers.localData(), p);
- pointers.setLocalData(0);
- QCOMPARE(pointers.localData(), (Pointer *)0);
+ pointers.setLocalData(nullptr);
+ QCOMPARE(pointers.localData(), nullptr);
QVERIFY(!pointers.hasLocalData());
}
@@ -102,8 +102,8 @@ void tst_QThreadStorage::localData_const()
pointers.setLocalData(p);
QVERIFY(pointers.hasLocalData());
QCOMPARE(const_pointers.localData(), p);
- pointers.setLocalData(0);
- QCOMPARE(const_pointers.localData(), (Pointer *)0);
+ pointers.setLocalData(nullptr);
+ QCOMPARE(const_pointers.localData(), nullptr);
QVERIFY(!pointers.hasLocalData());
}
@@ -113,7 +113,7 @@ void tst_QThreadStorage::setLocalData()
QVERIFY(!pointers.hasLocalData());
pointers.setLocalData(new Pointer);
QVERIFY(pointers.hasLocalData());
- pointers.setLocalData(0);
+ pointers.setLocalData(nullptr);
QVERIFY(!pointers.hasLocalData());
}
@@ -157,7 +157,7 @@ void tst_QThreadStorage::autoDelete()
QCOMPARE(Pointer::count, c);
}
-bool threadStorageOk;
+static bool threadStorageOk;
void testAdoptedThreadStorageWin(void *p)
{
QThreadStorage<Pointer *> *pointers = reinterpret_cast<QThreadStorage<Pointer *> *>(p);
@@ -183,7 +183,7 @@ void testAdoptedThreadStorageWin(void *p)
void *testAdoptedThreadStorageUnix(void *pointers)
{
testAdoptedThreadStorageWin(pointers);
- return 0;
+ return nullptr;
}
void tst_QThreadStorage::adoptedThreads()
{
@@ -194,9 +194,9 @@ void tst_QThreadStorage::adoptedThreads()
{
#ifdef Q_OS_UNIX
pthread_t thread;
- const int state = pthread_create(&thread, 0, testAdoptedThreadStorageUnix, &pointers);
+ const int state = pthread_create(&thread, nullptr, testAdoptedThreadStorageUnix, &pointers);
QCOMPARE(state, 0);
- pthread_join(thread, 0);
+ pthread_join(thread, nullptr);
#elif defined Q_OS_WIN
HANDLE thread;
thread = (HANDLE)_beginthread(testAdoptedThreadStorageWin, 0, &pointers);
@@ -212,7 +212,7 @@ void tst_QThreadStorage::adoptedThreads()
QTRY_COMPARE(Pointer::count, c);
}
-QBasicAtomicInt cleanupOrder = Q_BASIC_ATOMIC_INITIALIZER(0);
+static QBasicAtomicInt cleanupOrder = Q_BASIC_ATOMIC_INITIALIZER(0);
class First
{
diff --git a/tests/auto/corelib/thread/qwaitcondition/tst_qwaitcondition.cpp b/tests/auto/corelib/thread/qwaitcondition/tst_qwaitcondition.cpp
index 3fcac48788..9706f34236 100644
--- a/tests/auto/corelib/thread/qwaitcondition/tst_qwaitcondition.cpp
+++ b/tests/auto/corelib/thread/qwaitcondition/tst_qwaitcondition.cpp
@@ -95,7 +95,7 @@ public:
QWaitCondition *cond;
inline wait_QMutex_Thread_2()
- : mutex(0), cond(0)
+ : mutex(nullptr), cond(nullptr)
{ }
void run() override
@@ -134,7 +134,7 @@ public:
QWaitCondition *cond;
inline wait_QReadWriteLock_Thread_2()
- : readWriteLock(0), cond(0)
+ : readWriteLock(nullptr), cond(nullptr)
{ }
void run() override
@@ -392,7 +392,7 @@ public:
QWaitCondition *cond;
inline wake_Thread()
- : mutex(0), cond(0)
+ : mutex(nullptr), cond(nullptr)
{ }
static inline void sleep(ulong s)
@@ -424,7 +424,7 @@ public:
QWaitCondition *cond;
inline wake_Thread_2()
- : readWriteLock(0), cond(0)
+ : readWriteLock(nullptr), cond(nullptr)
{ }
static inline void sleep(ulong s)
diff --git a/tests/auto/corelib/thread/qwritelocker/tst_qwritelocker.cpp b/tests/auto/corelib/thread/qwritelocker/tst_qwritelocker.cpp
index 3dc3c37961..fd0f2d8d7e 100644
--- a/tests/auto/corelib/thread/qwritelocker/tst_qwritelocker.cpp
+++ b/tests/auto/corelib/thread/qwritelocker/tst_qwritelocker.cpp
@@ -109,7 +109,7 @@ void tst_QWriteLocker::scopeTest()
QVERIFY(thread->wait());
delete thread;
- thread = 0;
+ thread = nullptr;
}
@@ -156,7 +156,7 @@ void tst_QWriteLocker::unlockAndRelockTest()
QVERIFY(thread->wait());
delete thread;
- thread = 0;
+ thread = nullptr;
}
void tst_QWriteLocker::lockerStateTest()
@@ -196,7 +196,7 @@ void tst_QWriteLocker::lockerStateTest()
QVERIFY(thread->wait());
delete thread;
- thread = 0;
+ thread = nullptr;
}
QTEST_MAIN(tst_QWriteLocker)