From 94f74fa92e677e28c1ef560f9a8a039f9cf69579 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 21 Jul 2019 22:41:38 +0200 Subject: Fix some warnings --- pugl/pugl_internal.h | 2 +- pugl/pugl_x11.c | 16 ++++++++-------- pugl/pugl_x11_cairo.c | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pugl/pugl_internal.h b/pugl/pugl_internal.h index fea5959..3da435a 100644 --- a/pugl/pugl_internal.h +++ b/pugl/pugl_internal.h @@ -216,7 +216,7 @@ puglSetEventFunc(PuglView* view, PuglEventFunc eventFunc) static inline uint32_t puglDecodeUTF8(const uint8_t* buf) { -#define FAIL_IF(cond) { if (cond) return 0xFFFD; } +#define FAIL_IF(cond) do { if (cond) return 0xFFFD; } while (0) // http://en.wikipedia.org/wiki/UTF-8 diff --git a/pugl/pugl_x11.c b/pugl/pugl_x11.c index c42ccb9..398ae05 100644 --- a/pugl/pugl_x11.c +++ b/pugl/pugl_x11.c @@ -247,7 +247,7 @@ keySymToSpecial(KeySym sym) case XK_Alt_R: return PUGL_KEY_ALT; case XK_Super_L: return PUGL_KEY_SUPER; case XK_Super_R: return PUGL_KEY_SUPER; - default: return (PuglKey)0; + default: break; } return (PuglKey)0; } @@ -261,7 +261,7 @@ translateKey(PuglView* view, XEvent* xevent, PuglEventKey* event) event->filter = XFilterEvent(xevent, None); if (xevent->type == KeyRelease || event->filter || !view->impl->xic) { if (XLookupString(&xevent->xkey, str, 7, &sym, NULL) == 1) { - event->character = str[0]; + event->character = (uint8_t)str[0]; } } else { /* TODO: Not sure about this. On my system, some characters work with @@ -304,7 +304,7 @@ translateEvent(PuglView* view, XEvent xevent) switch (xevent.type) { case ClientMessage: if (xevent.xclient.message_type == view->impl->atoms.WM_PROTOCOLS) { - const Atom protocol = xevent.xclient.data.l[0]; + const Atom protocol = (Atom)xevent.xclient.data.l[0]; if (protocol == view->impl->atoms.WM_DELETE_WINDOW) { event.type = PUGL_CLOSE; } @@ -357,10 +357,10 @@ translateEvent(PuglView* view, XEvent xevent) event.scroll.dx = 0.0; event.scroll.dy = 0.0; switch (xevent.xbutton.button) { - case 4: event.scroll.dy = 1.0f; break; - case 5: event.scroll.dy = -1.0f; break; - case 6: event.scroll.dx = -1.0f; break; - case 7: event.scroll.dx = 1.0f; break; + case 4: event.scroll.dy = 1.0; break; + case 5: event.scroll.dy = -1.0; break; + case 6: event.scroll.dx = -1.0; break; + case 7: event.scroll.dx = 1.0; break; } // fallthru } @@ -564,7 +564,7 @@ puglPostRedisplay(PuglView* view) PuglNativeWindow puglGetNativeWindow(PuglView* view) { - return view->impl->win; + return (PuglNativeWindow)view->impl->win; } void* diff --git a/pugl/pugl_x11_cairo.c b/pugl/pugl_x11_cairo.c index bd427f8..8febe46 100644 --- a/pugl/pugl_x11_cairo.c +++ b/pugl/pugl_x11_cairo.c @@ -61,7 +61,7 @@ puglX11CairoCreate(PuglView* view) return 1; } - int st = cairo_surface_status(surface->surface); + cairo_status_t st = cairo_surface_status(surface->surface); if (st) { fprintf(stderr, "error: failed to create cairo surface (%s)\n", cairo_status_to_string(st)); @@ -72,7 +72,7 @@ puglX11CairoCreate(PuglView* view) fprintf(stderr, "error: cairo context is invalid (%s)\n", cairo_status_to_string(st)); } - return st; + return (int)st; } static int -- cgit v1.2.1