From a780e5b3638a0ff81301fc68aca15b47ba0befb7 Mon Sep 17 00:00:00 2001 From: Benjamin Tissoires Date: Wed, 14 Apr 2010 17:27:51 +0200 Subject: [PATCH] xf86ScaleAxis: support for high resolution devices High resolution devices was generating integer overflow. For instance the wacom Cintiq 21UX has an axis value up to 87000. Thus the term (dSx * (Cx - Rxlow)) is greater than MAX_INT32. Using 64bits integer avoids such problem. Signed-off-by: Philippe Ribet Signed-off-by: Benjamin Tissoires Reviewed-by: Keith Packard Signed-off-by: Peter Hutterer --- hw/xfree86/common/xf86Xinput.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c index 7723ba683..dba3370f3 100644 --- a/hw/xfree86/common/xf86Xinput.c +++ b/hw/xfree86/common/xf86Xinput.c @@ -86,6 +86,7 @@ #include "windowstr.h" /* screenIsSaved */ #include +#include /* for int64_t */ #include @@ -1177,12 +1178,11 @@ xf86ScaleAxis(int Cx, int Rxlow ) { int X; - int dSx = Sxhigh - Sxlow; - int dRx = Rxhigh - Rxlow; + int64_t dSx = Sxhigh - Sxlow; + int64_t dRx = Rxhigh - Rxlow; - dSx = Sxhigh - Sxlow; if (dRx) { - X = ((dSx * (Cx - Rxlow)) / dRx) + Sxlow; + X = (int)(((dSx * (Cx - Rxlow)) / dRx) + Sxlow); } else { X = 0;