From 8a0f0d0ca343e406aab7161c883187f1d2b85d89 Mon Sep 17 00:00:00 2001
From: Corentin Chary <corentincj@iksaif.net>
Date: Wed, 19 May 2010 09:24:02 +0200
Subject: [PATCH] vnc: explain why set_encodings loop is reversed

Add a small comment to explain why we need to start from
the end of the array to set the right prefered encoding.

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
 vnc.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/vnc.c b/vnc.c
index 1fb46bdc76..774a0b315a 100644
--- a/vnc.c
+++ b/vnc.c
@@ -1649,6 +1649,11 @@ static void set_encodings(VncState *vs, int32_t *encodings, size_t n_encodings)
     vs->tight_quality = 9;
     vs->absolute = -1;
 
+    /*
+     * Start from the end because the encodings are sent in order of preference.
+     * This way the prefered encoding (first encoding defined in the array)
+     * will be set at the end of the loop.
+     */
     for (i = n_encodings - 1; i >= 0; i--) {
         enc = encodings[i];
         switch (enc) {
-- 
2.30.2