diff options
author | Marc Mutz <marc.mutz@qt.io> | 2021-12-16 13:50:21 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2022-01-03 12:22:53 +0100 |
commit | 591a35d6fd9fa4f14ca1ac6a568673e2a2da0f60 (patch) | |
tree | b6f6ef2ba7fb2c2a8e78239be1234561f87c7aea /src/corelib/thread/qthread_p.h | |
parent | c953e5c41750ec886880cfb2cedb89f2886e5424 (diff) |
QThread: fix UB (invalid enum value) on Private::Priority
The Unix code stores an additional flag, ThreadPriorityResetFlag, in
the Policy enum, but ubsan does not approve:
qthread_unix.cpp:303:30: runtime error: load of value 2147483648, which is not a valid value for type 'Priority'
qthread_unix.cpp:304:75: runtime error: load of value 2147483648, which is not a valid value for type 'Priority'
Fix by making the variable of std::underlying_type_t<Priority>.
The masking and unmasking code can now be simplified, too.
In the Windows version, replace some switch targets with equivalent
ones to keep -Wswitch-like warnings, though I hasten to note that both
switches use a default case, so have anyway implicitly disabled said
warning.
Pick-to: 6.3 6.2 5.15
Change-Id: Ie4ea7d05e2928d2755ad12d36535197f85493191
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/corelib/thread/qthread_p.h')
-rw-r--r-- | src/corelib/thread/qthread_p.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/corelib/thread/qthread_p.h b/src/corelib/thread/qthread_p.h index 50d86ab51a..0a3813ab3b 100644 --- a/src/corelib/thread/qthread_p.h +++ b/src/corelib/thread/qthread_p.h @@ -164,7 +164,7 @@ public: int returnCode; uint stackSize; - QThread::Priority priority; + std::underlying_type_t<QThread::Priority> priority; #ifdef Q_OS_UNIX QWaitCondition thread_done; |