From cbb39709b9a7c3529d023c582e360f5db640ff4d Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Fri, 18 Jun 2021 10:01:33 +0200 Subject: [PATCH] uwac: Fixed warnings, added assertions --- uwac/libuwac/uwac-clipboard.c | 2 +- uwac/libuwac/uwac-input.c | 12 +++++++----- uwac/libuwac/uwac-output.c | 4 ++-- uwac/libuwac/uwac-priv.h | 4 ++-- uwac/libuwac/uwac-window.c | 15 ++++++++++----- 5 files changed, 22 insertions(+), 15 deletions(-) diff --git a/uwac/libuwac/uwac-clipboard.c b/uwac/libuwac/uwac-clipboard.c index 8296ddfa7..f61379d1a 100644 --- a/uwac/libuwac/uwac-clipboard.c +++ b/uwac/libuwac/uwac-clipboard.c @@ -54,7 +54,7 @@ static void data_offer_offer(void* data, struct wl_data_offer* data_offer, else { event->seat = seat; - sprintf_s(event->mime, sizeof(event->mime), "%s", offered_mime_type); + snprintf(event->mime, sizeof(event->mime), "%s", offered_mime_type); } } } diff --git a/uwac/libuwac/uwac-input.c b/uwac/libuwac/uwac-input.c index 6be1cae18..1662a219f 100644 --- a/uwac/libuwac/uwac-input.c +++ b/uwac/libuwac/uwac-input.c @@ -23,7 +23,9 @@ #include "uwac-utils.h" #include +#include #include +#include #include #include #include @@ -71,8 +73,8 @@ static struct wl_buffer* create_pointer_buffer(UwacSeat* seat, const void* src, wl_shm_pool_destroy(pool); if (munmap(data, size) < 0) - fprintf(stderr, "%s: munmap(%p, %" PRIuz ") failed with [%d] %s\n", __FUNCTION__, data, - size, errno, strerror(errno)); + fprintf(stderr, "%s: munmap(%p, %zu) failed with [%d] %s\n", __func__, data, size, errno, + strerror(errno)); error_mmap: close(fd); @@ -1020,7 +1022,7 @@ UwacSeat* UwacSeatNew(UwacDisplay* d, uint32_t id, uint32_t version) ret->xkb_context = xkb_context_new(0); if (!ret->xkb_context) { - fprintf(stderr, "%s: unable to allocate a xkb_context\n", __FUNCTION__); + fprintf(stderr, "%s: unable to allocate a xkb_context\n", __func__); goto error_xkb_context; } @@ -1031,13 +1033,13 @@ UwacSeat* UwacSeatNew(UwacDisplay* d, uint32_t id, uint32_t version) ret->repeat_timer_fd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK); if (ret->repeat_timer_fd < 0) { - fprintf(stderr, "%s: error creating repeat timer\n", __FUNCTION__); + fprintf(stderr, "%s: error creating repeat timer\n", __func__); goto error_timer_fd; } ret->repeat_task.run = keyboard_repeat_func; if (UwacDisplayWatchFd(d, ret->repeat_timer_fd, EPOLLIN, &ret->repeat_task) < 0) { - fprintf(stderr, "%s: error polling repeat timer\n", __FUNCTION__); + fprintf(stderr, "%s: error polling repeat timer\n", __func__); goto error_watch_timerfd; } diff --git a/uwac/libuwac/uwac-output.c b/uwac/libuwac/uwac-output.c index 7acb426d5..94210fb8f 100644 --- a/uwac/libuwac/uwac-output.c +++ b/uwac/libuwac/uwac-output.c @@ -45,7 +45,7 @@ static void output_handle_geometry(void* data, struct wl_output* wl_output, int if (!output->make) { assert(uwacErrorHandler(output->display, UWAC_ERROR_NOMEMORY, "%s: unable to strdup make\n", - __FUNCTION__)); + __func__)); } if (output->model) @@ -54,7 +54,7 @@ static void output_handle_geometry(void* data, struct wl_output* wl_output, int if (!output->model) { assert(uwacErrorHandler(output->display, UWAC_ERROR_NOMEMORY, - "%s: unable to strdup model\n", __FUNCTION__)); + "%s: unable to strdup model\n", __func__)); } UwacEvent* event = UwacDisplayNewEvent(output->display, UWAC_EVENT_OUTPUT_GEOMETRY); diff --git a/uwac/libuwac/uwac-priv.h b/uwac/libuwac/uwac-priv.h index aed38986a..9a2efe53e 100644 --- a/uwac/libuwac/uwac-priv.h +++ b/uwac/libuwac/uwac-priv.h @@ -237,8 +237,8 @@ struct uwac_window struct wl_region* opaque_region; struct wl_region* input_region; - SSIZE_T drawingBufferIdx; - SSIZE_T pendingBufferIdx; + ssize_t drawingBufferIdx; + ssize_t pendingBufferIdx; struct wl_surface* surface; struct wl_shell_surface* shell_surface; struct xdg_surface* xdg_surface; diff --git a/uwac/libuwac/uwac-window.c b/uwac/libuwac/uwac-window.c index bf70af2f1..52beb3ee8 100644 --- a/uwac/libuwac/uwac-window.c +++ b/uwac/libuwac/uwac-window.c @@ -362,9 +362,9 @@ error_mmap: return ret; } -static UwacBuffer* UwacWindowFindFreeBuffer(UwacWindow* w, SSIZE_T* index) +static UwacBuffer* UwacWindowFindFreeBuffer(UwacWindow* w, ssize_t* index) { - SSIZE_T i; + ssize_t i; int ret; if (index) @@ -629,7 +629,7 @@ static const struct wl_callback_listener frame_listener = { frame_done_cb }; #ifdef HAVE_PIXMAN_REGION static void damage_surface(UwacWindow* window, UwacBuffer* buffer) { - UINT32 nrects, i; + int nrects, i; const pixman_box32_t* box = pixman_region32_rectangles(&buffer->damage, &nrects); for (i = 0; i < nrects; i++, box++) @@ -641,7 +641,7 @@ static void damage_surface(UwacWindow* window, UwacBuffer* buffer) #else static void damage_surface(UwacWindow* window, UwacBuffer* buffer) { - UINT32 nrects, i; + uint32_t nrects, i; const RECTANGLE_16* box = region16_rects(&buffer->damage, &nrects); for (i = 0; i < nrects; i++, box++) @@ -681,7 +681,12 @@ static void frame_done_cb(void* data, struct wl_callback* callback, uint32_t tim UwacReturnCode UwacWindowAddDamage(UwacWindow* window, uint32_t x, uint32_t y, uint32_t width, uint32_t height) { - UwacBuffer* buf = window->drawingBuffer; + UwacBuffer* buf; + + if (window->drawingBufferIdx < 0) + return UWAC_ERROR_INTERNAL; + + buf = &window->buffers[window->drawingBufferIdx]; if (!pixman_region32_union_rect(&buf->damage, &buf->damage, x, y, width, height)) return UWAC_ERROR_INTERNAL;