Received: from [140.186.70.92] (port=46450 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OJYeY-00009w-CS for qemu-devel@nongnu.org; Tue, 01 Jun 2010 17:05:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OJYeV-0006hO-23 for qemu-devel@nongnu.org; Tue, 01 Jun 2010 17:05:37 -0400 Received: from iksaif.net ([88.191.73.63]:56773) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OJYeU-0006gz-Q1 for qemu-devel@nongnu.org; Tue, 01 Jun 2010 17:05:34 -0400 From: Corentin Chary Date: Tue, 1 Jun 2010 23:05:42 +0200 Message-Id: <1275426344-26549-2-git-send-email-corentincj@iksaif.net> In-Reply-To: <1275426344-26549-1-git-send-email-corentincj@iksaif.net> References: <1275426344-26549-1-git-send-email-corentincj@iksaif.net> Subject: [Qemu-devel] [PATCH 1/3] vnc: tight: don't forget last pixel in tight_encode_indexed_rect List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Corentin Chary , Anthony Liguori , Alexander Graf , Adam Litke 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,18 +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, rep; \ 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)) { \ -- 1.7.1