From e5c0a80b13ec4d2eca00c6e654939ac9fd61c1f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Sun, 27 Oct 2024 09:18:39 +0100 Subject: [PATCH] fixup! Clean up the erts_bs_get_integer_2() function in erl_bits.c --- erts/emulator/beam/erl_bits.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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) {