Re: [PATCH virt-viewer 07/19] Run-time check values before doing bad computation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi

On Tue, Jul 17, 2012 at 11:10 AM, Christophe Fergeau
<cfergeau@xxxxxxxxxx> 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


[Index of Archives]     [Linux Virtualization]     [KVM Development]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]     [Video 4 Linux]

  Powered by Linux