]> granicus.if.org Git - openjpeg/commitdiff
[trunk] Fix a warning about type conversion. Use a trick where unsigned wrapping...
authorMathieu Malaterre <mathieu.malaterre@gmail.com>
Mon, 24 Feb 2014 08:52:44 +0000 (08:52 +0000)
committerMathieu Malaterre <mathieu.malaterre@gmail.com>
Mon, 24 Feb 2014 08:52:44 +0000 (08:52 +0000)
src/lib/openjp2/bio.c

index 797e01e1a4c2a649801059bef073042797d388d2..213a99415c6bde1c123a37fda20515d3e3b0c186 100644 (file)
@@ -146,17 +146,17 @@ void opj_bio_init_dec(opj_bio_t *bio, OPJ_BYTE *bp, OPJ_UINT32 len) {
 }
 
 void opj_bio_write(opj_bio_t *bio, OPJ_UINT32 v, OPJ_UINT32 n) {
-       OPJ_INT32 i;
-       for (i = n - 1; i >= 0; i--) {
+       OPJ_UINT32 i;
+       for (i = n - 1; i < n; i--) {
                opj_bio_putbit(bio, (v >> i) & 1);
        }
 }
 
 OPJ_UINT32 opj_bio_read(opj_bio_t *bio, OPJ_UINT32 n) {
-       OPJ_INT32 i;
+       OPJ_UINT32 i;
     OPJ_UINT32 v;
        v = 0;
-       for (i = n - 1; i >= 0; i--) {
+       for (i = n - 1; i < n; i--) {
                v += opj_bio_getbit(bio) << i;
        }
        return v;