diff options
author | Thomas Gschwantner <tharre3@gmail.com> | 2018-06-15 20:04:12 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-06-18 15:08:56 +0200 |
commit | aeef9e5922f25bf572a008b11bb344b63461049e (patch) | |
tree | 175a1babbf1362a80e140f30bec723410bff4fc3 | |
parent | selftest/mpmc_ring: Add more __init/__initdata annotations (diff) | |
download | wireguard-monolithic-historical-aeef9e5922f25bf572a008b11bb344b63461049e.tar.xz wireguard-monolithic-historical-aeef9e5922f25bf572a008b11bb344b63461049e.zip |
selftest/mpmc_ring: use int64_t for counters
Previously used long would overflow on 32-bit machines.
-rw-r--r-- | src/selftest/mpmc_ring.h | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/selftest/mpmc_ring.h b/src/selftest/mpmc_ring.h index 251456f..1cea5bf 100644 --- a/src/selftest/mpmc_ring.h +++ b/src/selftest/mpmc_ring.h @@ -12,7 +12,7 @@ #define THREADS_PRODUCER 16 #define THREADS_CONSUMER 16 -#define ELEMENT_COUNT 1000000L /* divisible by threads_{consumer,producer} */ +#define ELEMENT_COUNT 1000000LL /* divisible by threads_{consumer,producer} */ #define QUEUE_SIZE 1024 #define EXPECTED_TOTAL ((ELEMENT_COUNT * (ELEMENT_COUNT + 1)) / 2) @@ -30,8 +30,8 @@ struct worker_producer { struct worker_consumer { struct work_struct work; int thread_num; - long total; - long count; + int64_t total; + int64_t count; }; static __init void producer_function(struct work_struct *work) @@ -66,7 +66,7 @@ bool __init mpmc_ring_selftest(void) struct workqueue_struct *wq; struct worker_producer *producers; struct worker_consumer *consumers; - long total = 0, count = 0; + int64_t total = 0, count = 0; int i; producers = kmalloc_array(THREADS_PRODUCER, sizeof(*producers), GFP_KERNEL); @@ -113,8 +113,8 @@ bool __init mpmc_ring_selftest(void) } pr_info("mpmc_ring self-test failed:"); - pr_info("Count: %lu, expected: %lu", count, ELEMENT_COUNT); - pr_info("Total: %lu, expected: %lu", total, EXPECTED_TOTAL); + pr_info("Count: %lld, expected: %lld", count, ELEMENT_COUNT); + pr_info("Total: %lld, expected: %lld", total, EXPECTED_TOTAL); return false; } |