diff --git a/erts/emulator/beam/erl_bits.c b/erts/emulator/beam/erl_bits.c index 52e6a8092d6e..0b5535426165 100644 --- a/erts/emulator/beam/erl_bits.c +++ b/erts/emulator/beam/erl_bits.c @@ -216,12 +216,13 @@ erts_bs_get_integer_2(Process *p, Uint num_bits, byte_offset = BYTE_OFFSET(sb->start); bp = erl_sub_bits_get_base(sb) + byte_offset; + offs = BIT_OFFSET(sb->start); /* * Special cases for field sizes up to the size of Uint. */ - if (num_bits <= 8-(offs = BIT_OFFSET(sb->start))) { + if (num_bits <= 8 - offs) { /* * All bits are in one byte in the binary. We only need * shift them right and mask them. @@ -239,10 +240,9 @@ erts_bs_get_integer_2(Process *p, Uint num_bits, * mask to extract the bits. */ Uint w = bp[0] << 8 | bp[1]; - Uint mask = MAKE_MASK(num_bits); sb->start += num_bits; w >>= 16 - offs - num_bits; - w &= mask; + w &= MAKE_MASK(num_bits); MAYBE_SIGN_EXTEND(flags, w, num_bits); return make_small(w); } else if (num_bits < SMALL_BITS && (flags & BSF_LITTLE) == 0) {