fix sc_sub_bits with non 8*x bitsizes
authorMatthias Braun <matze@braunis.de>
Mon, 10 Dec 2007 12:38:46 +0000 (12:38 +0000)
committerMatthias Braun <matze@braunis.de>
Mon, 10 Dec 2007 12:38:46 +0000 (12:38 +0000)
[r16929]

ir/tv/strcalc.c

index 47c9475..06dd22c 100644 (file)
@@ -1309,8 +1309,8 @@ unsigned char sc_sub_bits(const void *value, int len, unsigned byte_ofs) {
                res |= _val(val[nibble_ofs + 1]) << 4;
 
        /* kick bits outsize */
-       if (len < (int) (8*byte_ofs)) {
-               res &= 0xFF >> (8*byte_ofs - len);
+       if (len - 8 * byte_ofs < 8) {
+               res &= (1 << (len - 8 * byte_ofs)) - 1;
        }
        return res;
 }