Clean up undefined behavior in complicated and/or/shift expression

Shifting negative values is technically undefined, and we can describe
what we want to do in ways that are easier to read.
This commit is contained in:
Karl Mikaelsson 2017-10-20 13:24:52 +02:00
parent d037db1086
commit 43a4c89cef

6
mppc.c
View File

@ -349,9 +349,9 @@ mppc_expand(uint8 * data, uint32 clen, uint8 ctype, uint32 * roff, uint32 * rlen
}
match_bits = match_len;
match_len =
((walker >> (32 - match_bits)) & (~(-1 << match_bits))) | (1 <<
match_bits);
match_len = (walker >> (32 - match_bits));
match_len &= ((1 << match_bits) - 1);
match_len |= (1 << match_bits);
walker <<= match_bits;
walker_len -= match_bits;
}