From 49136d3e9fe2d065090ee90c18a49f65fb027c9f Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 26 Jun 2007 19:43:54 +0930 Subject: [PATCH] mieqEnqueue: use modulo for queue tail wrapping. This was previously committed by Michael Daenzer, but was lost during a pull. --- mi/mieq.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/mi/mieq.c b/mi/mieq.c index ff20003fc..4b299509d 100644 --- a/mi/mieq.c +++ b/mi/mieq.c @@ -119,7 +119,7 @@ mieqInit(void) void mieqEnqueue(DeviceIntPtr pDev, xEvent *e) { - HWEventQueueType oldtail = miEventQueue.tail, newtail; + unsigned int oldtail = miEventQueue.tail, newtail; EventListPtr evt; int isMotion = 0; int evlen; @@ -138,7 +138,7 @@ mieqEnqueue(DeviceIntPtr pDev, xEvent *e) EventPtr laste; deviceKeyButtonPointer *lastkbp; - laste = &miEventQueue.events[(oldtail ? oldtail : QUEUE_SIZE) - 1]; + laste = &miEventQueue.events[(oldtail - 1) % QUEUE_SIZE]; lastkbp = (deviceKeyButtonPointer *) laste->events->event; if (laste->nevents > 6) { @@ -161,9 +161,7 @@ mieqEnqueue(DeviceIntPtr pDev, xEvent *e) if (isMotion && isMotion == miEventQueue.lastMotion && oldtail != miEventQueue.head) { - if (oldtail == 0) - oldtail = QUEUE_SIZE; - oldtail = oldtail - 1; + oldtail = (oldtail - 1) % QUEUE_SIZE; } else { newtail = (oldtail + 1) % QUEUE_SIZE;