diff options
author | David Robillard <d@drobilla.net> | 2021-05-25 10:19:48 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2021-05-25 10:36:55 -0400 |
commit | 040e94b26395451b78f5cbe0b7f208afcf28af1b (patch) | |
tree | 6f622347d0f7b1cd0df4757663acbf4ca34a3926 | |
parent | a5674908ca0832ef6f89fee49150c6743a09c0ef (diff) | |
download | pugl-040e94b26395451b78f5cbe0b7f208afcf28af1b.tar.gz pugl-040e94b26395451b78f5cbe0b7f208afcf28af1b.tar.bz2 pugl-040e94b26395451b78f5cbe0b7f208afcf28af1b.zip |
Fix some conversion warnings
Avoids narrowing warnings when building as C++, and uses unsigned operands with
bitwise operators in various places.
-rw-r--r-- | src/mac_gl.m | 4 | ||||
-rw-r--r-- | src/win.c | 12 |
2 files changed, 8 insertions, 8 deletions
diff --git a/src/mac_gl.m b/src/mac_gl.m index dd06cc0..24d3846 100644 --- a/src/mac_gl.m +++ b/src/mac_gl.m @@ -73,8 +73,8 @@ NSOpenGLPFAColorSize, colorSize, NSOpenGLPFADepthSize, (unsigned)puglview->hints[PUGL_DEPTH_BITS], NSOpenGLPFAStencilSize, (unsigned)puglview->hints[PUGL_STENCIL_BITS], - NSOpenGLPFAMultisample, samples ? 1 : 0, - NSOpenGLPFASampleBuffers, samples ? 1 : 0, + NSOpenGLPFAMultisample, samples ? 1u : 0u, + NSOpenGLPFASampleBuffers, samples ? 1u : 0u, NSOpenGLPFASamples, samples, 0}; // clang-format on @@ -385,11 +385,11 @@ puglDecodeUTF16(const wchar_t* buf, const int len) { const uint32_t c0 = buf[0]; const uint32_t c1 = buf[0]; - if (c0 >= 0xD800 && c0 < 0xDC00) { + if (c0 >= 0xD800u && c0 < 0xDC00u) { if (len < 2) { return 0xFFFD; // Surrogate, but length is only 1 - } else if (c1 >= 0xDC00 && c1 <= 0xDFFF) { - return ((c0 & 0x03FF) << 10) + (c1 & 0x03FF) + 0x10000; + } else if (c1 >= 0xDC00u && c1 <= 0xDFFFu) { + return ((c0 & 0x03FFu) << 10u) + (c1 & 0x03FFu) + 0x10000u; } return 0xFFFD; // Unpaired surrogates @@ -418,7 +418,7 @@ initKeyEvent(PuglEventKey* event, const unsigned vcode = MapVirtualKey(vkey, MAPVK_VK_TO_VSC); const unsigned kchar = MapVirtualKey(vkey, MAPVK_VK_TO_CHAR); - const bool dead = kchar >> (sizeof(UINT) * 8 - 1) & 1; + const bool dead = kchar >> (sizeof(UINT) * 8u - 1u) & 1u; const bool ext = lParam & 0x01000000; event->type = press ? PUGL_KEY_PRESS : PUGL_KEY_RELEASE; @@ -451,8 +451,8 @@ initKeyEvent(PuglEventKey* event, static void initCharEvent(PuglEvent* event, PuglView* view, WPARAM wParam, LPARAM lParam) { - const wchar_t utf16[2] = {wParam & 0xFFFF, - (wchar_t)((wParam >> 16) & 0xFFFF)}; + const wchar_t utf16[2] = {(wchar_t)(wParam & 0xFFFFu), + (wchar_t)((wParam >> 16u) & 0xFFFFu)}; initKeyEvent(&event->key, view, true, wParam, lParam); event->type = PUGL_TEXT; |