> I don't see your patch reversing the logic? > > Alex > > Before my patch (not this one, but http://git.qemu.org/qemu.git/commit/?id=14eb8b6829ad9dee7035de729e083844a425f274 ), we looped from the last encoding to the first (for (i = n_encodings - 1; i >= 0; i--)), so the code was ok.
Commit 14eb8b6829ad9dee7035de729e083844a425f274 was wrong because I wanted `if (encoding == -1) encoding = enc`, not `if (encoding != -1) encoding = enc`. With the current code the encoding will never be set and will always be -1. And this patch (refactor set_encoding) is also wrong, because it will only set the first encoding (which is in fact the last, because we start from the end of the array). I believe that the right thing to do is to revert 14eb8b6829ad9dee7035de729e083844a425f274 and add some comments to explain why we loop in reverse order. -- Corentin Chary http://xf.iksaif.net