summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-07-17 19:35:53 +0200
committerDavid Robillard <d@drobilla.net>2020-07-17 20:44:52 +0200
commitb50a5872fca8a4086502d7c19e80bc9992782079 (patch)
tree07a4df6bd59076c7ecf543c0928fdf08a3deb104
parent0887b4035da053931bee16fafc7800a05f2ce775 (diff)
downloadraul-b50a5872fca8a4086502d7c19e80bc9992782079.tar.gz
raul-b50a5872fca8a4086502d7c19e80bc9992782079.tar.bz2
raul-b50a5872fca8a4086502d7c19e80bc9992782079.zip
Fix conversion warnings
-rw-r--r--raul/Semaphore.hpp5
-rw-r--r--test/ringbuffer_test.cpp16
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);