[PATCH] dix: Untwist transformAbsolute logic, eliminate uninitialized value warnings

Peter Hutterer peter.hutterer at who-t.net
Tue Oct 28 20:46:18 PDT 2014


On Wed, Oct 22, 2014 at 02:48:10PM -0700, Keith Packard wrote:
> tranformAbsolute has a pretty simple job, that of running the X/Y
> values from a device through the transformation matrix. The tricky bit
> comes when the current device state doesn't include one of the
> values. In that case, the last delivered value is back-converted to
> device space and used instead.
> 
> The logic was twisted though, confusing GCC's uninitialized value
> detection logic and emitting warnings.
> 
> This has been fixed by changing the code to:
> 
>  1) Detect whether the ValuatorMask includes X/Y values
>  2) If either are missing, back-convert the current values into ox/oy
>  3) When X/Y are present, set ox/oy to the current value
>  4) Transform
>  5) Store X/Y values if changed or if they were set before.
> 
> Signed-off-by: Keith Packard <keithp at keithp.com>
> Cc: Peter Hutterer <peter.hutterer at who-t.net>

Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
please merge at your leisure.

Cheers,
   Peter

> ---
>  dix/getevents.c | 22 +++++++++++-----------
>  1 file changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/dix/getevents.c b/dix/getevents.c
> index ffa89fa..dd96265 100644
> --- a/dix/getevents.c
> +++ b/dix/getevents.c
> @@ -1248,8 +1248,8 @@ transformAbsolute(DeviceIntPtr dev, ValuatorMask *mask)
>      double x, y, ox, oy;
>      int has_x, has_y;
>  
> -    has_x = valuator_mask_fetch_double(mask, 0, &ox);
> -    has_y = valuator_mask_fetch_double(mask, 1, &oy);
> +    has_x = valuator_mask_isset(mask, 0);
> +    has_y = valuator_mask_isset(mask, 1);
>  
>      if (!has_x && !has_y)
>          return;
> @@ -1263,23 +1263,23 @@ transformAbsolute(DeviceIntPtr dev, ValuatorMask *mask)
>  
>          pixman_f_transform_invert(&invert, &dev->scale_and_transform);
>          transform(&invert, &ox, &oy);
> -
> -        x = ox;
> -        y = oy;
>      }
>  
> -    if (valuator_mask_isset(mask, 0))
> -        ox = x = valuator_mask_get_double(mask, 0);
> +    if (has_x)
> +        ox = valuator_mask_get_double(mask, 0);
>  
> -    if (valuator_mask_isset(mask, 1))
> -        oy = y = valuator_mask_get_double(mask, 1);
> +    if (has_y)
> +        oy = valuator_mask_get_double(mask, 1);
> +
> +    x = ox;
> +    y = oy;
>  
>      transform(&dev->scale_and_transform, &x, &y);
>  
> -    if (valuator_mask_isset(mask, 0) || ox != x)
> +    if (has_x || ox != x)
>          valuator_mask_set_double(mask, 0, x);
>  
> -    if (valuator_mask_isset(mask, 1) || oy != y)
> +    if (has_y || oy != y)
>          valuator_mask_set_double(mask, 1, y);
>  }
>  
> -- 
> 2.1.1
> 


More information about the xorg-devel mailing list