Received: from eggs.gnu.org ([2001:4830:134:3::10]:39215) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WMxAP-0004y4-IN for qemu-devel@nongnu.org; Mon, 10 Mar 2014 06:10:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WMxAJ-0005uI-70 for qemu-devel@nongnu.org; Mon, 10 Mar 2014 06:10:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:5176) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WMxAI-0005u1-TN for qemu-devel@nongnu.org; Mon, 10 Mar 2014 06:10:35 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s2AAAYAE010479 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 10 Mar 2014 06:10:34 -0400 From: Markus Armbruster References: <1392997372-6224-1-git-send-email-armbru@redhat.com> Date: Mon, 10 Mar 2014 11:10:31 +0100 In-Reply-To: <1392997372-6224-1-git-send-email-armbru@redhat.com> (Markus Armbruster's message of "Fri, 21 Feb 2014 16:42:52 +0100") Message-ID: <878usie548.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH] vnc: Fix tight_detect_smooth_image() for lossless case List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kraxel@redhat.com Ping? Markus Armbruster writes: > VncTight member uint8_t quality is either (uint8_t)-1 for lossless or > less than 10 for lossy. > > tight_detect_smooth_image() first promotes it to int, then compares > with -1. Always unequal, so we always execute the lossy code. Reads > beyond tight_conf[] and returns crap when quality is actually > lossless. > > Compare to (uint8_t)-1 instead, like we do elsewhere. > > Spotted by Coverity. > > Signed-off-by: Markus Armbruster > --- > ui/vnc-enc-tight.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/ui/vnc-enc-tight.c b/ui/vnc-enc-tight.c > index e6966ae..59b59c0 100644 > --- a/ui/vnc-enc-tight.c > +++ b/ui/vnc-enc-tight.c > @@ -330,7 +330,7 @@ tight_detect_smooth_image(VncState *vs, int w, int h) > } else { > errors = tight_detect_smooth_image16(vs, w, h); > } > - if (quality != -1) { > + if (quality != (uint8_t)-1) { > return (errors < tight_conf[quality].jpeg_threshold); > } > return (errors < tight_conf[compression].gradient_threshold);