]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
compression: Replace divisions with shifts
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Mon, 7 Mar 2022 23:21:02 +0000 (12:21 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 12 May 2022 02:22:35 +0000 (02:22 +0000)
This is more consistent with the compression code.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
lib/compression/lzxpress.c

index 2669700ada5c0d600a7bf8403d3ae6b70bdad6ce..18d0c3183a6007b081d92f584412dc85088349bb 100644 (file)
@@ -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;
                                }