QSemaphore: Fix warnings about shift exceeding size on 32-bit

error: right shift count >= width of type [-Werror=shift-count-overflow]

Fixes: QTBUG-105687
Change-Id: Ic6547f8247454b47baa8fffd170bd9cd0e2a8ca3
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
(cherry picked from commit 1022922037e794f3687d7c58f8b2caa44343a43b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Thiago Macieira 2022-08-16 07:32:42 -07:00 committed by Qt Cherry-pick Bot
parent 5bf5159011
commit 6676b7ca69

View File

@ -161,7 +161,7 @@ futexSemaphoreTryAcquire_loop(QBasicAtomicInteger<quintptr> &u, quintptr curValu
if constexpr (futexHasWaiterCount) {
Q_ASSERT(n > 1);
ptr = futexHigh32(&u);
curValue >>= 32;
curValue = quint64(curValue) >> 32;
}
}
@ -213,7 +213,8 @@ template <bool IsTimed> bool futexSemaphoreTryAcquire(QBasicAtomicInteger<quintp
if constexpr (futexHasWaiterCount) {
// We don't use the fetched value from above so futexWait() fails if
// it changed after the testAndSetOrdered above.
if (((curValue >> 32) & 0x7fffffffU) == 0x7fffffffU) {
quint32 waiterCount = (quint64(curValue) >> 32) & 0x7fffffffU;
if (waiterCount == 0x7fffffffU) {
qCritical() << "Waiter count overflow in QSemaphore";
return false;
}