diff options
-rw-r--r-- | raul/Semaphore.hpp | 5 | ||||
-rw-r--r-- | test/ringbuffer_test.cpp | 16 |
2 files changed, 11 insertions, 10 deletions
diff --git a/raul/Semaphore.hpp b/raul/Semaphore.hpp index 0eb1703..ee2325f 100644 --- a/raul/Semaphore.hpp +++ b/raul/Semaphore.hpp @@ -158,7 +158,7 @@ Semaphore::timed_wait(const std::chrono::duration<Rep, Period>& wait) inline bool Semaphore::init(unsigned initial) { - if (!(_sem = CreateSemaphore(NULL, initial, LONG_MAX, NULL))) { + if (!(_sem = CreateSemaphore(NULL, (LONG)initial, LONG_MAX, NULL))) { return false; } return true; @@ -198,7 +198,8 @@ Semaphore::timed_wait(const std::chrono::duration<Rep, Period>& wait) namespace chr = std::chrono; const chr::milliseconds ms(chr::duration_cast<chr::milliseconds>(wait)); - return WaitForSingleObject(_sem, ms.count()) == WAIT_OBJECT_0; + return WaitForSingleObject( + _sem, static_cast<DWORD>(ms.count())) == WAIT_OBJECT_0; } #else /* !defined(__APPLE__) && !defined(_WIN32) */ 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 <string> #include <thread> -#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<uint32_t>(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<RingBuffer>(new RingBuffer(uint32_t(size))); + ctx.ring = std::unique_ptr<RingBuffer>(new RingBuffer(size)); auto& ring = ctx.ring; assert(ring->capacity() >= size - 1); |