From 040e94b26395451b78f5cbe0b7f208afcf28af1b Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 25 May 2021 10:19:48 -0400 Subject: Fix some conversion warnings Avoids narrowing warnings when building as C++, and uses unsigned operands with bitwise operators in various places. --- src/mac_gl.m | 4 ++-- 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 diff --git a/src/win.c b/src/win.c index cb97cdd..0510536 100644 --- a/src/win.c +++ b/src/win.c @@ -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; -- cgit v1.2.1