summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2017-07-06 05:56:03 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2017-07-06 17:07:12 +0200
commite8a3fad62f1c3379110645a902e42c58ea80d425 (patch)
treead91ab7145eec5590c39a8e3a26263a0b807ebd5 /src
parent1516abda241e47b29b17f13404f9c5a98e9efc71 (diff)
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. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src')
-rw-r--r--src/data.c6
1 files 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);