[virt-tools-list] [PATCH virt-viewer 07/19] Run-time check values before doing bad computation
Marc-André Lureau
marcandre.lureau at gmail.com
Tue Jul 17 11:03:57 UTC 2012
Hi
On Tue, Jul 17, 2012 at 11:10 AM, Christophe Fergeau
<cfergeau at redhat.com> wrote:
>> + if (priv->desktopWidth == 0 ||
>> + priv->desktopHeight == 0)
>> + goto end;
>
> Why can this happen?
It the spice display doesn't know, for example, we don't yet have
monitor geometry.
>> + g_return_if_fail(fullscreen.height > 128);
>> + g_return_if_fail(fullscreen.width > 128);
>> + g_return_if_fail(desktopWidth > 0);
>> + g_return_if_fail(desktopHeight > 0);
>
> In size_allocate 0 width/height are silently ignored, here you return with
> a warning, is it on purpose?
This is the following code:
desktopAspect = (double)desktopWidth / (double)desktopHeight;
screenAspect = (double)(fullscreen.width - 128) /
(double)(fullscreen.height - 128);
if ((desktopWidth > (fullscreen.width - 128)) ||
(desktopHeight > (fullscreen.height - 128))) {
I wanted a bit of run-time check, in practice we don't seem to hit
these condition, but you can see it would be nice to have a warning if
it happens.
--
Marc-André Lureau
More information about the virt-tools-list
mailing list