Patchwork [v3,02/12] vnc: explain why set_encodings loop is reversed

login
register
mail settings
Submitter Corentin Chary
Date May 19, 2010, 7:24 a.m.
Message ID <1274253852-16068-3-git-send-email-corentincj@iksaif.net>
Download mbox | patch
Permalink /patch/52955/
State New
Headers show

Comments

Corentin Chary - May 19, 2010, 7:24 a.m.
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>
---
 vnc.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

Patch

diff --git a/vnc.c b/vnc.c
index b1a3fdb..d0402b9 100644
--- a/vnc.c
+++ b/vnc.c
@@ -1599,6 +1599,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) {