Fixed an operator precedence issue in codel_impl.h

The get_next_interval_sqrt function has the line:
__u64 val = (__u64)CODEL_EXCEED_INTERVAL << 16 / get_sqrt_sh16(cnt);

However, the division operator has higher precedence than the shift
operator. Therefore, 16 / get_sqrt_sh16(cnt) will always evaluate to zero.

Signed-off-by: Frey Alfredsson <freysteinn@freysteinn.com>
This commit is contained in:
Frey Alfredsson
2022-10-13 17:09:12 +02:00
parent 7a9db7b08c
commit 3f73da760a

View File

@@ -69,7 +69,7 @@ static __always_inline __u32 get_sqrt_sh16(__u64 cnt)
static __always_inline __u64 get_next_interval_sqrt(__u64 cnt)
{
__u64 val = (__u64)CODEL_EXCEED_INTERVAL << 16 / get_sqrt_sh16(cnt);
__u64 val = ((__u64)CODEL_EXCEED_INTERVAL << 16) / get_sqrt_sh16(cnt);
return val;
}