From: Joseph Sutton Date: Mon, 7 Mar 2022 23:21:02 +0000 (+1300) Subject: compression: Replace divisions with shifts X-Git-Tag: talloc-2.3.4~159 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fe5fa7e19740896c21ab374cbf1f0f44a0412c94;p=thirdparty%2Fsamba.git compression: Replace divisions with shifts This is more consistent with the compression code. Signed-off-by: Joseph Sutton Reviewed-by: Douglas Bagnall --- diff --git a/lib/compression/lzxpress.c b/lib/compression/lzxpress.c index 2669700ada5..18d0c3183a6 100644 --- a/lib/compression/lzxpress.c +++ b/lib/compression/lzxpress.c @@ -257,20 +257,21 @@ ssize_t lzxpress_decompress(const uint8_t *input, } else { uint32_t length; uint32_t offset; + CHECK_INPUT_BYTES(sizeof(uint16_t)); length = PULL_LE_U16(input, input_index); input_index += sizeof(uint16_t); - offset = (length / 8) + 1; - length = length % 8; + offset = (length >> 3) + 1; + length &= 7; if (length == 7) { if (nibble_index == 0) { CHECK_INPUT_BYTES(sizeof(uint8_t)); nibble_index = input_index; - length = input[input_index] % 16; + length = input[input_index] & 0xf; input_index += sizeof(uint8_t); } else { - length = input[nibble_index] / 16; + length = input[nibble_index] >> 4; nibble_index = 0; }