From b50a5872fca8a4086502d7c19e80bc9992782079 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 17 Jul 2020 19:35:53 +0200 Subject: Fix conversion warnings --- test/ringbuffer_test.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'test/ringbuffer_test.cpp') diff --git a/test/ringbuffer_test.cpp b/test/ringbuffer_test.cpp index 519b0c3..709af9e 100644 --- a/test/ringbuffer_test.cpp +++ b/test/ringbuffer_test.cpp @@ -27,7 +27,7 @@ #include #include -#define MSG_SIZE 20 +#define MSG_SIZE 20u namespace { @@ -41,7 +41,7 @@ struct Context { int gen_msg(int* msg, int start) { - for (int i = 0; i < MSG_SIZE; ++i) { + for (unsigned i = 0u; i < MSG_SIZE; ++i) { msg[i] = start; start = (start + 1) % INT_MAX; } @@ -51,7 +51,7 @@ gen_msg(int* msg, int start) void check_msg(int* msg1, int* msg2) { - for (int i = 0; i < MSG_SIZE; ++i) { + for (unsigned i = 0u; i < MSG_SIZE; ++i) { assert(msg1[i] == msg2[i]); } } @@ -108,20 +108,20 @@ main(int argc, char** argv) Context ctx; - size_t size = 512; + uint32_t size = 512u; if (argc > 1) { - size = std::stoul(argv[1]); + size = static_cast(std::stoi(argv[1])); } - ctx.n_writes = size * 1024; + ctx.n_writes = size * 1024u; if (argc > 2) { ctx.n_writes = std::stoul(argv[2]); } - printf("Testing %zu writes of %u ints to a %zu int ring...\n", + printf("Testing %zu writes of %u ints to a %u int ring...\n", ctx.n_writes, MSG_SIZE, size); - ctx.ring = std::unique_ptr(new RingBuffer(uint32_t(size))); + ctx.ring = std::unique_ptr(new RingBuffer(size)); auto& ring = ctx.ring; assert(ring->capacity() >= size - 1); -- cgit v1.2.1