[PATCH] test/xi2: Really fix infinite loop in test_convert_XITouchOwnershipEvent

Chase Douglas chase.douglas at canonical.com
Thu Dec 22 12:00:37 PST 2011


long i;
for (i = 1; ; i <<= 1)
  if (i == (1 << 31))
    break;

(1 << 31) is compiled as an int, and thus is equal to -2147483648. We
are trying to compare it against a long, which on 64-bit machines is
2147483648. This results in an infinite loop.

Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
---
 test/xi2/protocol-eventconvert.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/test/xi2/protocol-eventconvert.c b/test/xi2/protocol-eventconvert.c
index faa9f40..bf1493c 100644
--- a/test/xi2/protocol-eventconvert.c
+++ b/test/xi2/protocol-eventconvert.c
@@ -1005,7 +1005,7 @@ test_convert_XITouchOwnershipEvent(void)
     {
         in.touchid = i;
         test_XITouchOwnershipEvent(&in);
-	if (i == (1 << 31))
+	if (i == ((long)1 << 31))
 	    break;
     }
 }
-- 
1.7.5.4



More information about the xorg-devel mailing list