aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorThomas Gschwantner <tharre3@gmail.com>2018-06-15 20:04:12 +0200
committerThomas Gschwantner <tharre3@gmail.com>2018-06-15 20:04:12 +0200
commit18da924f273bd89571601a9c240b0813e5c4dedb (patch)
treea65cd22f4c4361ecfbe8eed3cbc9c8608c020e16
parentselftest/mpmc_ring: Add more __init/__initdata annotations (diff)
downloadwireguard-monolithic-historical-18da924f273bd89571601a9c240b0813e5c4dedb.tar.xz
wireguard-monolithic-historical-18da924f273bd89571601a9c240b0813e5c4dedb.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.h12
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;
}