From: Mathieu Malaterre Date: Mon, 24 Feb 2014 08:52:44 +0000 (+0000) Subject: [trunk] Fix a warning about type conversion. Use a trick where unsigned wrapping... X-Git-Tag: version.2.0.1~4^2~259 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=33d8f08964ca48183241d680ccd692378e25cc70;p=openjpeg [trunk] Fix a warning about type conversion. Use a trick where unsigned wrapping is legal --- diff --git a/src/lib/openjp2/bio.c b/src/lib/openjp2/bio.c index 797e01e1..213a9941 100644 --- a/src/lib/openjp2/bio.c +++ b/src/lib/openjp2/bio.c @@ -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;