Received: from eggs.gnu.org ([208.118.235.92]:39953) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TO0iZ-0003dT-3p for qemu-devel@nongnu.org; Tue, 16 Oct 2012 02:33:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TO0iV-00058x-Aq for qemu-devel@nongnu.org; Tue, 16 Oct 2012 02:33:31 -0400 Message-ID: <507CFFB3.7070907@msgid.tls.msk.ru> Date: Tue, 16 Oct 2012 10:33:23 +0400 From: Michael Tokarev MIME-Version: 1.0 References: <1349872258-21952-1-git-send-email-pbonzini@redhat.com> In-Reply-To: <1349872258-21952-1-git-send-email-pbonzini@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] vnc: fix "info vnc" with "-vnc ..., reverse=on" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-trivial@nongnu.org, qemu-devel@nongnu.org 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