CLEANUP: hpack: remove a redundant test in the decoder

As reported in issue #485 the test for !len at the end of the
loop in get_var_int() is useless since it was already done inside
the loop. Actually the code is more readable if we remove the first
one so let's do this instead. The resulting code is exactly the same
since the compiler already optimized the test away.
This commit is contained in:
Willy Tarreau 2020-02-05 15:28:55 +01:00
parent 4dd145a888
commit 077d366ef7

View File

@ -65,11 +65,7 @@ static uint32_t get_var_int(const uint8_t **raw_in, uint32_t *len_in, int b)
if (ret != (uint32_t)((1 << b) - 1))
goto end;
while (1) {
if (!len)
goto too_short;
if (!(*raw & 128))
break;
while (len && (*raw & 128)) {
ret += ((uint32_t)(*raw++) & 127) << shift;
shift += 7;
len--;