uwac: Fixed warnings, added assertions

This commit is contained in:
Armin Novak 2021-06-18 10:01:33 +02:00 committed by akallabeth
parent ea78e33d17
commit cbb39709b9
5 changed files with 22 additions and 15 deletions

View File

@ -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);
}
}
}

View File

@ -23,7 +23,9 @@
#include "uwac-utils.h"
#include <stdio.h>
#include <inttypes.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <assert.h>
#include <errno.h>
@ -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;
}

View File

@ -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);

View File

@ -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;

View File

@ -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;