Fixed sign-compare warnings
authorArmin Novak <armin.novak@thincast.com>
Thu, 7 Feb 2019 13:21:04 +0000 (14:21 +0100)
committerArmin Novak <armin.novak@thincast.com>
Fri, 5 Apr 2019 07:13:24 +0000 (09:13 +0200)
uwac/libuwac/uwac-display.c
uwac/libuwac/uwac-input.c
uwac/libuwac/uwac-output.c
uwac/libuwac/uwac-tools.c

index af389e5..41c9d2c 100644 (file)
 #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;
 }
index 34afb26..7cc6d51 100644 (file)
@@ -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++) {
index 8176b94..2fa03c8 100644 (file)
@@ -27,7 +27,7 @@
 #include <string.h>
 #include <assert.h>
 
-#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,
index 73aff22..c3d27c4 100644 (file)
@@ -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;