From 0cadfc6954dbc1b61f11d949b4961c455e4fca8e Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Thu, 6 Jul 2017 05:56:03 +0200 Subject: counter: use correct unit for indices Even though redundant bits == bits per long, we're indexing into something that uses longs as its unit, so this is correct. --- src/data.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/data.c b/src/data.c index 59e9714..be6bf7f 100644 --- a/src/data.c +++ b/src/data.c @@ -68,10 +68,10 @@ static inline bool counter_validate(union noise_counter *counter, u64 their_coun if (unlikely((COUNTER_WINDOW_SIZE + their_counter) < counter->receive.counter)) goto out; - index = their_counter >> ilog2(COUNTER_REDUNDANT_BITS); + index = their_counter >> ilog2(BITS_PER_LONG); if (likely(their_counter > counter->receive.counter)) { - index_current = counter->receive.counter >> ilog2(COUNTER_REDUNDANT_BITS); + index_current = counter->receive.counter >> ilog2(BITS_PER_LONG); top = min_t(unsigned long, index - index_current, COUNTER_BITS_TOTAL / BITS_PER_LONG); for (i = 1; i <= top; ++i) counter->receive.backtrack[(i + index_current) & ((COUNTER_BITS_TOTAL / BITS_PER_LONG) - 1)] = 0; @@ -79,7 +79,7 @@ static inline bool counter_validate(union noise_counter *counter, u64 their_coun } index &= (COUNTER_BITS_TOTAL / BITS_PER_LONG) - 1; - ret = !test_and_set_bit(their_counter & (COUNTER_REDUNDANT_BITS - 1), &counter->receive.backtrack[index]); + ret = !test_and_set_bit(their_counter & (BITS_PER_LONG - 1), &counter->receive.backtrack[index]); out: spin_unlock_bh(&counter->receive.lock); -- cgit v1.2.3-59-g8ed1b