On Fri, Apr 9, 2010 at 7:51 AM, Benjamin Tissoires <[email protected]> wrote:
> 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 <[email protected]>
> Signed-off-by: Benjamin Tissoires <[email protected]>
> ---
>  hw/xfree86/common/xf86Xinput.c |    6 +++---
>  1 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
> index 8229227..80bdd19 100644
> --- a/hw/xfree86/common/xf86Xinput.c
> +++ b/hw/xfree86/common/xf86Xinput.c
> @@ -1172,12 +1172,12 @@ 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;

Not sure, but would you not also need to change the function
parameters to int64_t? I guess you're just avoiding a cast below,
though. Also, could you explicitly include <stdint.h> instead of
getting it implicitly?

>
>     dSx = Sxhigh - Sxlow;

Could you kill this redundant line while you're at it?

>     if (dRx) {
> -       X = ((dSx * (Cx - Rxlow)) / dRx) + Sxlow;
> +       X = (int)(((dSx * (Cx - Rxlow)) / dRx) + Sxlow);
>     }
>     else {
>        X = 0;
> --
> 1.6.6.1

--
Dan
_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to