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_win.cpp | |
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_win.cpp')
-rw-r--r-- | src/corelib/thread/qthread_win.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp index 820ffa1149..4b144ebda4 100644 --- a/src/corelib/thread/qthread_win.cpp +++ b/src/corelib/thread/qthread_win.cpp @@ -457,7 +457,7 @@ void QThread::start(Priority priority) int prio; d->priority = priority; - switch (d->priority) { + switch (priority) { case IdlePriority: prio = THREAD_PRIORITY_IDLE; break; @@ -584,7 +584,7 @@ void QThreadPrivate::setPriority(QThread::Priority threadPriority) int prio; priority = threadPriority; - switch (priority) { + switch (threadPriority) { case QThread::IdlePriority: prio = THREAD_PRIORITY_IDLE; break; |