[virt-tools-list] [PATCH virt-viewer 07/19] Run-time check values before doing bad computation
Christophe Fergeau
cfergeau at redhat.com
Tue Jul 17 12:54:35 UTC 2012
On Tue, Jul 17, 2012 at 01:03:57PM +0200, Marc-André Lureau wrote:
> 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.
Yes I've seen why you wanted these checks, I was just curious about the
difference between the first hunk and this one.
>
> --
> Marc-André Lureau
>
> _______________________________________________
> virt-tools-list mailing list
> virt-tools-list at redhat.com
> https://www.redhat.com/mailman/listinfo/virt-tools-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/virt-tools-list/attachments/20120717/530c6e64/attachment.sig>
More information about the virt-tools-list
mailing list