From patchwork Thu May 27 06:21:52 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Chary X-Patchwork-Id: 53693 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 60597B6ED0 for ; Thu, 27 May 2010 16:32:04 +1000 (EST) Received: from localhost ([127.0.0.1]:44473 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OHWdN-00013l-Bu for incoming@patchwork.ozlabs.org; Thu, 27 May 2010 02:32:01 -0400 Received: from [140.186.70.92] (port=51061 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OHWTo-00022J-SC for qemu-devel@nongnu.org; Thu, 27 May 2010 02:22:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OHWTh-0001pE-KC for qemu-devel@nongnu.org; Thu, 27 May 2010 02:22:08 -0400 Received: from iksaif.net ([88.191.73.63]:43706) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OHWTh-0001oi-Ep for qemu-devel@nongnu.org; Thu, 27 May 2010 02:22:01 -0400 Received: from tartiflon (lal69-3-82-241-209-44.fbx.proxad.net [82.241.209.44]) (Authenticated sender: corentincj@iksaif.net) by iksaif.net (Postfix) with ESMTPA id D9716C9001F; Thu, 27 May 2010 08:25:53 +0200 (CEST) From: Corentin Chary To: qemu-devel@nongnu.org Date: Thu, 27 May 2010 08:21:52 +0200 Message-Id: <1274941314-7493-1-git-send-email-corentincj@iksaif.net> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1274253852-16068-1-git-send-email-corentincj@iksaif.net> References: <1274253852-16068-1-git-send-email-corentincj@iksaif.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) Cc: Corentin Chary , Anthony Liguori , Alexander Graf , Adam Litke Subject: [Qemu-devel] [PATCH 1/3] vnc: tight: don't forget last pixel in tight_encode_indexed_rect X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org A simple patch would have been to just remove count -= 1, but this one also replace the while (count--) with a for(i = 0; i < count; i++) which I believe is more easy to understand. Signed-off-by: Corentin Chary --- vnc-encoding-tight.c | 9 ++++----- 1 files changed, 4 insertions(+), 5 deletions(-) diff --git a/vnc-encoding-tight.c b/vnc-encoding-tight.c index 50be44e..c8effe6 100644 --- a/vnc-encoding-tight.c +++ b/vnc-encoding-tight.c @@ -249,17 +249,16 @@ static void print_palette(const char *key, QObject *obj, void *opaque) uint##bpp##_t *src; \ uint##bpp##_t rgb; \ uint8_t key[6]; \ - int rep = 0; \ + int i = 0, rep = 0; \ uint8_t idx; \ \ src = (uint##bpp##_t *) buf; \ \ - count -= 1; \ - while (count--) { \ + for (i = 0; i < count; i++) { \ rgb = *src++; \ rep = 0; \ - while (count && *src == rgb) { \ - rep++, src++, count--; \ + while (i < count && *src == rgb) { \ + rep++, src++, i++; \ } \ tight_palette_rgb2buf(rgb, bpp, key); \ if (!qdict_haskey(palette, (char *)key)) { \