qemu-trivial
[Top][All Lists]
Advanced

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

Re: [Qemu-trivial] [Qemu-devel] [PATCH] vnc: fix "info vnc" with "-vnc .


From: Michael Tokarev
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH] vnc: fix "info vnc" with "-vnc ..., reverse=on"
Date: Tue, 16 Oct 2012 10:33:23 +0400
User-agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:10.0.7) Gecko/20120922 Icedove/10.0.7

On 10.10.2012 16:30, Paolo Bonzini wrote:
[]
> --- a/ui/vnc.c
> +++ b/ui/vnc.c
> @@ -372,6 +372,10 @@ VncInfo *qmp_query_vnc(Error **errp)
>              }
>          }
>  
> +        if (vnc_display->lsock == -1) {

FWIW, can't we use "< 0" condition in all cases like this - for
testing whenever a filedescriptor is not open or if a system call
returned failure?  Why we compare with -1 only?  The "< 0" comparison
is cheaper in the resulting code (very very small difference), but
more to the point, it guarantees that no invalid value is treated
as valid - for example, in case some function returns -errno like
it was with bdrv_something() recently.  I use "< 0" in such places
for over 20 years for this reason, this "technique" saved me
countless number of times, when old API changed, or when I switched
to a new API without reviewing return value checking in all places,
or when I just didn't read the manpage carefully... ;)

Thanks,

/mjt



reply via email to

[Prev in Thread] Current Thread [Next in Thread]