From de69dd3942dad86c4a5c8bf5bd50d99d1089760e Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Thu, 7 Feb 2019 14:21:04 +0100 Subject: [PATCH] Fixed sign-compare warnings --- uwac/libuwac/uwac-display.c | 14 +++++++------- uwac/libuwac/uwac-input.c | 4 ++-- uwac/libuwac/uwac-output.c | 2 +- uwac/libuwac/uwac-tools.c | 11 +++++++---- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/uwac/libuwac/uwac-display.c b/uwac/libuwac/uwac-display.c index af389e5ac..41c9d2cd6 100644 --- a/uwac/libuwac/uwac-display.c +++ b/uwac/libuwac/uwac-display.c @@ -35,12 +35,12 @@ #include "uwac-os.h" #include "wayland-cursor.h" -#define TARGET_COMPOSITOR_INTERFACE 3 -#define TARGET_SHM_INTERFACE 1 -#define TARGET_SHELL_INTERFACE 1 -#define TARGET_DDM_INTERFACE 1 -#define TARGET_SEAT_INTERFACE 5 -#define TARGET_XDG_VERSION 5 /* The version of xdg-shell that we implement */ +#define TARGET_COMPOSITOR_INTERFACE 3U +#define TARGET_SHM_INTERFACE 1U +#define TARGET_SHELL_INTERFACE 1U +#define TARGET_DDM_INTERFACE 1U +#define TARGET_SEAT_INTERFACE 5U +#define TARGET_XDG_VERSION 5U /* The version of xdg-shell that we implement */ static const char* event_names[] = { @@ -683,7 +683,7 @@ UwacReturnCode UwacDisplayQueryShmFormats(const UwacDisplay* display, enum wl_sh if (!display) return UWAC_ERROR_INVALID_DISPLAY; - *filled = min(display->shm_formats_nb, formats_size); + *filled = min((int64_t)display->shm_formats_nb, formats_size); memcpy(formats, (const void*)display->shm_formats, *filled * sizeof(enum wl_shm_format)); return UWAC_SUCCESS; } diff --git a/uwac/libuwac/uwac-input.c b/uwac/libuwac/uwac-input.c index 34afb26c7..7cc6d51a3 100644 --- a/uwac/libuwac/uwac-input.c +++ b/uwac/libuwac/uwac-input.c @@ -235,7 +235,7 @@ static void keyboard_handle_enter(void *data, struct wl_keyboard *keyboard, uint { uint32_t *key, *pressedKey; UwacSeat *input = (UwacSeat *)data; - int i, found; + size_t i, found; UwacKeyboardEnterLeaveEvent *event; event = (UwacKeyboardEnterLeaveEvent *)UwacDisplayNewEvent(input->display, UWAC_EVENT_KEYBOARD_ENTER); @@ -309,7 +309,7 @@ static int update_key_pressed(UwacSeat *seat, uint32_t key) { static int update_key_released(UwacSeat *seat, uint32_t key) { uint32_t *keyPtr; - int i, toMove; + size_t i, toMove; bool found = false; for (i = 0, keyPtr = seat->pressed_keys.data; i < seat->pressed_keys.size; i++, keyPtr++) { diff --git a/uwac/libuwac/uwac-output.c b/uwac/libuwac/uwac-output.c index 8176b9447..2fa03c8c8 100644 --- a/uwac/libuwac/uwac-output.c +++ b/uwac/libuwac/uwac-output.c @@ -27,7 +27,7 @@ #include #include -#define TARGET_OUTPUT_INTERFACE 2 +#define TARGET_OUTPUT_INTERFACE 2U static void output_handle_geometry(void *data, struct wl_output *wl_output, int x, int y, int physical_width, int physical_height, int subpixel, diff --git a/uwac/libuwac/uwac-tools.c b/uwac/libuwac/uwac-tools.c index 73aff227e..c3d27c4b2 100644 --- a/uwac/libuwac/uwac-tools.c +++ b/uwac/libuwac/uwac-tools.c @@ -47,10 +47,10 @@ bool UwacTouchAutomataInjectEvent(UwacTouchAutomata *automata, UwacEvent *event) case UWAC_EVENT_TOUCH_UP: { UwacTouchUp *touchUp = &event->touchUp; - int toMove = automata->tp.size - sizeof(UwacTouchPoint); + size_t toMove = automata->tp.size - sizeof(UwacTouchPoint); wl_array_for_each(tp, &automata->tp) { - if (tp->id == touchUp->id) { + if ((int64_t)tp->id == touchUp->id) { if (toMove) memmove(tp, tp+1, toMove); return true; @@ -65,7 +65,7 @@ bool UwacTouchAutomataInjectEvent(UwacTouchAutomata *automata, UwacEvent *event) UwacTouchDown *touchDown = &event->touchDown; wl_array_for_each(tp, &automata->tp) { - if (tp->id == touchDown->id) { + if ((int64_t)tp->id == touchDown->id) { tp->x = touchDown->x; tp->y = touchDown->y; return true; @@ -76,7 +76,10 @@ bool UwacTouchAutomataInjectEvent(UwacTouchAutomata *automata, UwacEvent *event) if (!tp) return false; - tp->id = touchDown->id; + if (touchDown->id < 0) + return false; + + tp->id = (uint32_t)touchDown->id; tp->x = touchDown->x; tp->y = touchDown->y; break;