(CARD32 can be unsigned int or unsigned long, but the following applies to both, it's only a matter of signedness.)
Trying to compare two unsigned integers by diffing them and then casting that into a signed quantity is wrong in one half of all cases (i.e.: the difference is higher than maximal integer/2). Accordingly, replace all: (int) (foo-bar) <= 0 tests with: foo <= bar This is the first patch to fix the following bugs. Debian Bug 616667 <http://bugs.debian.org/616667> X.Org Bug 35066 <http://bugs.freedesktop.org/show_bug.cgi?id=35066> Signed-off-by: Cyril Brulebois <k...@debian.org> --- os/WaitFor.c | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-) diff --git a/os/WaitFor.c b/os/WaitFor.c index 867cb04..d44e00b 100644 --- a/os/WaitFor.c +++ b/os/WaitFor.c @@ -272,10 +272,10 @@ WaitForSomething(int *pClientsReady) { int expired = 0; now = GetTimeInMillis(); - if ((int) (timers->expires - now) <= 0) + if (timers->expires <= now) expired = 1; - while (timers && (int) (timers->expires - now) <= 0) + while (timers && (timers->expires <= now)) DoTimer(timers, now, &timers); if (expired) @@ -291,10 +291,10 @@ WaitForSomething(int *pClientsReady) { int expired = 0; now = GetTimeInMillis(); - if ((int) (timers->expires - now) <= 0) + if (timers->expires <= now) expired = 1; - while (timers && (int) (timers->expires - now) <= 0) + while (timers && (timers->expires <= now)) DoTimer(timers, now, &timers); if (expired) @@ -466,7 +466,7 @@ TimerSet(OsTimerPtr timer, int flags, CARD32 millis, timer->expires = millis; timer->callback = func; timer->arg = arg; - if ((int) (millis - now) <= 0) + if (millis <= now) { timer->next = NULL; millis = (*timer->callback)(timer, now, timer->arg); @@ -474,7 +474,7 @@ TimerSet(OsTimerPtr timer, int flags, CARD32 millis, return timer; } for (prev = &timers; - *prev && (int) ((*prev)->expires - millis) <= 0; + *prev && ((*prev)->expires <= millis); prev = &(*prev)->next) ; timer->next = *prev; @@ -530,7 +530,7 @@ TimerCheck(void) { CARD32 now = GetTimeInMillis(); - while (timers && (int) (timers->expires - now) <= 0) + while (timers && (timers->expires <= now)) DoTimer(timers, now, &timers); } -- 1.7.4.1 _______________________________________________ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel