Diffstat (limited to 'qmake/tools/qsemaphore_unix.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | qmake/tools/qsemaphore_unix.cpp | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/qmake/tools/qsemaphore_unix.cpp b/qmake/tools/qsemaphore_unix.cpp index fcf28da..4516049 100644 --- a/qmake/tools/qsemaphore_unix.cpp +++ b/qmake/tools/qsemaphore_unix.cpp | |||
@@ -185,2 +185,9 @@ int QSemaphore::operator+=(int n) | |||
185 | 185 | ||
186 | if ( n < 0 || n > d->max ) { | ||
187 | #ifdef QT_CHECK_RANGE | ||
188 | qWarning( "QSemaphore::operator+=: paramter %d out of range", n ); | ||
189 | #endif // QT_CHECK_RANGE | ||
190 | n = n < 0 ? 0 : d->max; | ||
191 | } | ||
192 | |||
186 | while (d->value + n > d->max) | 193 | while (d->value + n > d->max) |
@@ -189,10 +196,2 @@ int QSemaphore::operator+=(int n) | |||
189 | d->value += n; | 196 | d->value += n; |
190 | |||
191 | #ifdef QT_CHECK_RANGE | ||
192 | if (d->value > d->max) { | ||
193 | qWarning("QSemaphore::operator+=: attempt to allocate more resources than available"); | ||
194 | d->value = d->max; | ||
195 | } | ||
196 | #endif | ||
197 | |||
198 | ret = d->value; | 197 | ret = d->value; |
@@ -214,11 +213,10 @@ int QSemaphore::operator-=(int n) | |||
214 | 213 | ||
215 | d->value -= n; | 214 | if ( n < 0 || n > d->value ) { |
216 | |||
217 | #ifdef QT_CHECK_RANGE | 215 | #ifdef QT_CHECK_RANGE |
218 | if (d->value < 0) { | 216 | qWarning( "QSemaphore::operator-=: paramter %d out of range", n ); |
219 | qWarning("QSemaphore::operator-=: attempt to deallocate more resources than taken"); | 217 | #endif // QT_CHECK_RANGE |
220 | d->value = 0; | 218 | n = n < 0 ? 0 : d->value; |
221 | } | 219 | } |
222 | #endif | ||
223 | 220 | ||
221 | d->value -= n; | ||
224 | ret = d->value; | 222 | ret = d->value; |