From efc9744aa464f01eeeccc1b354b0564d819fdeb3 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 22 Apr 2022 16:06:05 -0400 Subject: Windows: Avoid else after return --- src/win.c | 12 +++++++++--- src/win_gl.c | 8 ++++++-- 2 files changed, 15 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/win.c b/src/win.c index b603b48..b90bce5 100644 --- a/src/win.c +++ b/src/win.c @@ -376,7 +376,9 @@ puglDecodeUTF16(const wchar_t* buf, const int len) if (c0 >= 0xD800u && c0 < 0xDC00u) { if (len < 2) { return 0xFFFD; // Surrogate, but length is only 1 - } else if (c1 >= 0xDC00u && c1 <= 0xDFFFu) { + } + + if (c1 >= 0xDC00u && c1 <= 0xDFFFu) { return ((c0 & 0x03FFu) << 10u) + (c1 & 0x03FFu) + 0x10000u; } @@ -1094,7 +1096,9 @@ puglSetClipboard(PuglView* const view, PuglStatus st = puglSetInternalClipboard(view, type, data, len); if (st) { return st; - } else if (!OpenClipboard(impl->hwnd)) { + } + + if (!OpenClipboard(impl->hwnd)) { return PUGL_UNKNOWN_ERROR; } @@ -1238,7 +1242,9 @@ puglWinCreateWindow(PuglView* const view, NULL, NULL))) { return PUGL_REALIZE_FAILED; - } else if (!(*hdc = GetDC(*hwnd))) { + } + + if (!(*hdc = GetDC(*hwnd))) { DestroyWindow(*hwnd); *hwnd = NULL; return PUGL_REALIZE_FAILED; diff --git a/src/win_gl.c b/src/win_gl.c index 718a93c..0a035a1 100644 --- a/src/win_gl.c +++ b/src/win_gl.c @@ -211,7 +211,9 @@ puglWinGlCreate(PuglView* view) // Create real window with desired pixel format if ((st = puglWinCreateWindow(view, "Pugl", &impl->hwnd, &impl->hdc))) { return st; - } else if (!SetPixelFormat(impl->hdc, impl->pfId, &impl->pfd)) { + } + + if (!SetPixelFormat(impl->hdc, impl->pfId, &impl->pfd)) { ReleaseDC(impl->hwnd, impl->hdc); DestroyWindow(impl->hwnd); impl->hwnd = NULL; @@ -224,7 +226,9 @@ puglWinGlCreate(PuglView* view) !(surface->hglrc = surface->procs.wglCreateContextAttribs( impl->hdc, 0, contextAttribs))) { return PUGL_CREATE_CONTEXT_FAILED; - } else if (!(surface->hglrc = wglCreateContext(impl->hdc))) { + } + + if (!(surface->hglrc = wglCreateContext(impl->hdc))) { return PUGL_CREATE_CONTEXT_FAILED; } -- cgit v1.2.1