[Spice-devel] [spice-gtk v1 3/3] Fix clang's double-promotion warning
Frediano Ziglio
fziglio at redhat.com
Wed Dec 20 13:31:29 UTC 2017
>
> From: Victor Toso <me at victortoso.com>
>
> Casting to gdouble instead to float to avoid the warning and perhaps
> increase the precision.
>
> spice-widget-egl.c:573:28: error: implicit conversion increases
> floating-point precision: 'float' to 'gdouble' (aka 'double')
> tx = ((float)d->area.x / (float)d->egl.scanout.width);
> ~ ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> spice-widget-egl.c:574:28: error: implicit conversion increases
> floating-point precision: 'float' to 'gdouble' (aka 'double')
> ty = ((float)d->area.y / (float)d->egl.scanout.height);
> ~ ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> spice-widget-egl.c:575:32: error: implicit conversion increases
> floating-point precision: 'float' to 'gdouble' (aka 'double')
> tw = ((float)d->area.width / (float)d->egl.scanout.width);
> ~ ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> spice-widget-egl.c:576:33: error: implicit conversion increases
> floating-point precision: 'float' to 'gdouble' (aka 'double')
> th = ((float)d->area.height / (float)d->egl.scanout.height);
> ~ ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Signed-off-by: Victor Toso <victortoso at redhat.com>
> ---
> src/spice-widget-egl.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/src/spice-widget-egl.c b/src/spice-widget-egl.c
> index 1e71753..5354e26 100644
> --- a/src/spice-widget-egl.c
> +++ b/src/spice-widget-egl.c
> @@ -570,10 +570,10 @@ void spice_egl_update_display(SpiceDisplay *display)
> glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
> glClear(GL_COLOR_BUFFER_BIT);
>
> - tx = ((float)d->area.x / (float)d->egl.scanout.width);
> - ty = ((float)d->area.y / (float)d->egl.scanout.height);
> - tw = ((float)d->area.width / (float)d->egl.scanout.width);
> - th = ((float)d->area.height / (float)d->egl.scanout.height);
> + tx = (gdouble) d->area.x / d->egl.scanout.width;
> + ty = (gdouble) d->area.y / d->egl.scanout.height;
> + tw = (gdouble) d->area.width / d->egl.scanout.width;
> + th = (gdouble) d->area.height / d->egl.scanout.height;
>
> /* convert to opengl coordinates, 0 is bottom, 1 is top. ty should
> * be the bottom of the area, since th is upward */
Acked-by: Frediano Ziglio <fziglio at redhat.com>
Frediano
More information about the Spice-devel
mailing list